1005 Spell It Right (20 分)
Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English.
Input Specification:
Each input file contains one test case. Each case occupies one line which contains an N (≤10100).
Output Specification:
For each test case, output in one line the digits of the sum in English words. There must be one space between two consecutive words, but no extra space at the end of a line.
Sample Input:
12345
Sample Output:
one five
#include<bits/stdc++.h>
using namespace std;
#define e exp(1)
#define pi acos(-1)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define ll long long
#define ull unsigned long long
#define mem(a,b) memset(a,b,sizeof(a))
int gcd(int a,int b){return b?gcd(b,a%b):a;}
string s[15]={"zero","one","two","three","four","five","six","seven","eight","nine"};
int main()
{
int num=0,cnt=0;
string ss,p[6];cin>>ss;
for(int i=0; i<ss.size(); i++)
{
num+=ss[i]-'0';
}
if(num==0)
{
cout<<s[0];
}
else {while(num)
{
p[cnt++]=s[num%10];
num/=10;
}
cout<<p[cnt-1];
for(int i=cnt-2; i>=0; i--)
{
cout<<" "<<p[i];
}
}
puts("");
return 0;
}