题目链接:https://pintia.cn/problem-sets/994805260223102976/problems/994805324509200384
1 #include <iostream> 2 #include <cstdio> 3 #include <string> 4 #include <cstring> 5 #include <algorithm> 6 #include <stack> 7 using namespace std; 8 char s[1005]; 9 string a[10]={"ling","yi","er","san","si","wu","liu","qi","ba","jiu"}; 10 int main() 11 { 12 while(scanf("%s",&s)!=EOF){ 13 int sum=0; 14 int len=strlen(s); 15 for(int i=0;i<len;i++){ 16 sum+=s[i]-'0'; 17 } 18 //cout<<sum<<endl; 19 stack<int> sta; 20 while(sum){ 21 sta.push(sum%10); 22 sum/=10; 23 } 24 while(!sta.empty()){ 25 cout<<a[sta.top()]; 26 sta.pop(); 27 if(!sta.empty()) cout<<' '; 28 } 29 cout<<endl; 30 } 31 return 0; 32 }