写出这个数(20)
1 #include <iostream> 2 #include <algorithm> 3 #include <string> 4 using namespace std; 5 const int maxn = 15; 6 string a; 7 char s[maxn][maxn] = { "ling", "yi", "er", "san", "si", "wu", "liu", "qi", "ba", "jiu" }; 8 int b[10005]; 9 10 int main(){ 11 12 while (cin >> a){ 13 int ans = 0; 14 for (char x : a){ 15 ans += x - '0'; 16 } 17 if (ans == 0){ 18 cout << "ling" << endl; 19 continue; 20 } 21 int len = 0; 22 while (ans){ 23 b[len++] = ans % 10; 24 ans /= 10; 25 } 26 for (int i = len - 1; i >= 0; i--){ 27 if (i == len - 1){ 28 cout << s[b[i]]; 29 } 30 else 31 cout << " " << s[b[i]]; 32 } 33 cout << endl; 34 } 35 36 //system("pause"); 37 return 0; 38 }