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:
https://pintia.cn/problem-sets/994805342720868352/problems/994805519074574336
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
Note that when this number is zero when the output zero
Remember the English word 0 to 9 (humble)
#include<bits/stdc++.h>
#pragma GCC optimize(3)
#define max(a,b) a>b?a:b
using namespace std;
typedef long long ll;
char s[105];
vector<int> v;
map<int,string> mp;
void init(){
mp[0]="zero";
mp[1]="one";
mp[2]="two";
mp[3]="three";
mp[4]="four";
mp[5]="five";
mp[6]="six";
mp[7]="seven";
mp[8]="eight";
mp[9]="nine";
}
int main(){
init();
scanf("%s",s+1);
int len=strlen(s+1);
int ans=0;
for(int i=1;i<=len;i++){
ans+=(s[i]-'0');
}
while(ans){
v.push_back(ans%10);
ans/=10;
}
for(int i=v.size()-1;i>=0;i--){
cout<<mp[v[i]];
if(i!=0) cout<<" ";
else cout<<"\n";
}
if(v.empty()) cout<<"zero"<<"\n";
return 0;
}