1005. Spell It Right (20)


时间限制



400 ms



内存限制



65536 kB



代码长度限制



16000 B



判题程序



Standard



作者



CHEN, Yue


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<stdio.h>
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<set>
#include<algorithm>
using namespace std;

int main()
{
string s;
cin >> s;
int i = 0; int sum = 0;
while (s[i] != '\0')
{
sum += s[i] - '0';
i++;
}
int temp; vector<int> v;
do
{
temp = sum % 10;
sum /= 10;
v.push_back(temp);
} while (sum);
for (int i = 0; i < v.size(); i++)
{
switch (v[v.size()-1-i])
{
case 0:cout << "zero"; break;
case 1:cout << "one"; break;
case 2:cout << "two"; break;
case 3:cout << "three"; break;
case 4:cout << "four"; break;
case 5:cout << "five"; break;
case 6:cout << "six"; break;
case 7:cout << "seven"; break;
case 8:cout << "eight"; break;
case 9:cout << "nine"; break;
default:
break;
}
if (i != v.size() - 1)
cout << " ";
}


}