代码:
#include<cstdio> #include<cstring> using namespace std; char s[105]; int a[100]; char num[12][100]; int main() { strcpy(num[0],"ling"); strcpy(num[1],"yi"); strcpy(num[2],"er"); strcpy(num[3],"san"); strcpy(num[4],"si"); strcpy(num[5],"wu"); strcpy(num[6],"liu"); strcpy(num[7],"qi"); strcpy(num[8],"ba"); strcpy(num[9],"jiu"); while(scanf("%s",s)==1) { int len=strlen(s); int ans=0; for(int i=0; i<len; i++) { ans+=(s[i]-'0'); } if(ans==0) printf("ling\n"); int i=0; while(ans>0) { int r=ans%10; a[i++]=r; ans=ans/10; } for(int j=i-1; j>=0; j--) { if(j==0) printf("%s\n",num[a[j]]); else printf("%s ",num[a[j]]); } } return 0; }
版权声明:本文为博主原创文章,未经博主允许不得转载。
时间: 2024-11-09 04:52:13