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 (≤10​100).

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

题目翻译:

给出一个非负整数N,计算N的各位置的和,并用英语将这个总和的数的每一位表示出来。

输入规范:

每个输入文件包含一个测试用例,每个包含N(≤10​100)的用例占据一行

输出规范:

对于每个测试用例,将每个用例数位上的和的英文输出在一行中,两个连续单词之间必须有空格,行尾不允许有额外空格。

代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
string str[10]={"zero","one","two","three","four","five","six","seven","eight","nine"};
int main(){
string s;
cin>>s;
int sum=0;
for(int i=0;i<s.length();i++)
sum+=(s[i]-'0');
string sum1=to_string(sum);
for(int i=0;i<sum1.length();i++){
cout<<str[sum1[i]-'0'];
if(i<sum1.length()-1)
cout<<" ";
}
return 0;
}