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

思路:
把输入的字符串放入string中,用string[i]求出和sum,再把sum转为string,输出。


#include <iostream>
#include <string>
using namespace std;
int main()
{
	string a;
	int sum = 0;
	cin >> a;
	for (int i = 0; i < a.length(); ++i)
		sum += a[i] - '0';
	string ELS[10] = { "zero","one", "two", "three", "four", "five", "six", "seven","eight","nine" };
	string ssum = to_string(sum);
	cout << ELS[ssum[0] - '0'] ;
	for (int i = 1; i < ssum.length(); ++i)
		cout <<' '<< ELS[ssum[i] - '0'];
	return 0;
}