1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| #include<stdio.h> #include<string.h> int main(){ char a[100]; int num = 0,ge,shi,bai; scanf("%s",&a); for(int i = 0;i < strlen(a);i++){ num = num + a[i] - '0'; } char *py[] = {"ling","yi","er","san","si","wu","liu","qi","ba","jiu"}; if (num>=100){ ge = num%10; shi = num/10%10; bai = num/100; printf("%s ",py[bai]); printf("%s ",py[shi]); printf("%s",py[ge]); } else if(num>=10){ ge = num%10; shi = num/10; printf("%s ",py[shi]); printf("%s",py[ge]); } else{ printf("%s",py[num]); } return 0; }
|