1005 Spell It Right

--write by zhuwx 2019-08-05 18:49:27 +0800 CST

Given a non-negative integer , your task is to compute the sum of all the digits of , 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  ().

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 <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#define N 999999999999

int main(){
std:: string ins;
std::cin >> ins;
if (ins == "0"){
std::cout << "zero";
return 0;
}
int count = 0;
for (int i=0; i<ins.size(); i++){
count+=(ins[i]-'0');
}
char answer[ins.size()];
int i=0;
while(count != 0){
answer[i] = count%10+'0';
++i;
count = count/10;
}
std::string num[10]={"zero","one","two","three","four","five","six","seven","eight","nine"};
for (int j=i-1; j>=0; j--){
if (answer[j] == 0){
std::cout << "zero" << std::endl;
break;
}
if (j!=0)
std::cout << num[answer[j]-'0'] <<" ";
else
std::cout << num[answer[j]-'0'];
}
return 0;
}