#include<stdio.h> #include<stdlib.h> #include<string.h> int main() { char str[111]; scanf("%s",str); int len=strlen(str); int sum=0; for(int i=0 ; i<len ; ++i) sum+=str[i]-‘0‘; char A[10][5]={"ling","yi","er","san","si","wu","liu","qi","ba","jiu"}; int out[50],index=0; while(sum!=0) //将结果下标倒序存入out { out[index++]=sum%10; sum/=10; } for(int i=index-1 ; i>=0 ; --i) //再讲结果逆序输出,就是正常的顺序了 { printf("%s",A[out[i]]); if(i!=0) printf(" "); } //system("pause"); return 0; }
时间: 2024-12-30 05:54:05