题意就是把数字的每一位加起来,得到一个和,这个和的每一位用英文输出。。注意0输出zero就是了。
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<stack>
#include<vector>
#include<queue>
#include<string>
#include<map>
using namespace std;
#define INF 99999999
#define M 10004
int num[M];
//16:51
int main()
{
int n;
string a[10]={"zero","one","two","three","four","five","six","seven","eight","nine"};
string nstr;
cin>>nstr;
int i,sum=0;
for(i=0;i<nstr.size();i++)
{
sum += nstr[i] - '0';
}
vector<string> ans;
if(sum==0)
{
cout<<"zero"<<endl;
return 0;
}
while(sum!=0)
{
ans.push_back(a[sum%10]);
sum/=10;
}
for(i=ans.size()-1;i>=0;i--)
{
cout<<ans[i];
if(i==0)
cout<<endl;
else cout<<" ";
}
}