#include<stdio.h> int main() { int n,a[10],i,m=0,p; char str1[10][3]={"零","一","二","三","四","五","六","七","八","九"}; char str2[5][5]={"十","百","千","万"}; printf("输入数字:"); scanf("%d",&n); for(i=0;i<10;i++) { a[i]=n%10; n=n/10; m++; if(n==0)break; } if(m>1) for(i=m-1;i>0;i--) { if(a[i]!=0) { p=a[i]; printf("%s%s",str1[p],str2[(i-1)%4]); } else if(i==4&&a[i]==0) printf("万"); else if(a[i-1]!=0) printf("零"); else continue; } p=a[0]; if(p!=0) printf("%s\n",str1[p]); else printf(" "); return 0; }
[此贴子已经被作者于2017-10-11 16:03编辑过]