#include<iostream>#include<string>#include<vector>#include<algorithm> usingnamespacestd;
intmain(){
string s;
cin >> s;
string result[] = { "ling","yi","er","san","si","wu","liu","qi","ba","jiu" };
longint sum = 0;
for (int i = 0; i < s.size(); i++) {
sum += s[i] - '0';
}
string res = to_string(sum);
for (int i = 0; i < res.size(); i++) {
if (i != 0)
cout << " ";
cout << result[res[i] - '0'];
}
cout << endl;
}
复制代码
python代码
result = [ "ling","yi","er","san","si","wu","liu","qi","ba","jiu" ]
sum = 0
s = input()
for a in s:
sum += int(a)
sum = str(sum)
for i,ch in enumerate(sum):
if i!=0:
print(" ",end='')
print(result[int(ch)],end='')
复制代码