分析
模拟题,输入字符串,逐个计算总和即可
C++ 代码
#include<bits/stdc++.h>
using namespace std;
int main()
{
int b=0;
string a; cin>>a;
for(int i=0;i<a.size();i++)
{
b+=a[i]-'0';
}
char d[10][10]={"zero","one","two","three","four","five","six","seven","eight","nine"};
string s=to_string(b);
string res;
for(int i=s.size()-1;i>=0;i--)
{
if(i>0)
{
res=d[s[i]-'0']+res;
res=" "+res;
}
else
res=d[s[i]-'0']+res;
}
cout<<res<<endl;
return 0;
}