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:12345Sample Output:
one five
#include <iostream>
#include <string>
using namespace std;
int flag = 1;
const char num[10][6] = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
void spell(int n)
{
if(n/10)
spell(n/10);
if(flag)
{
cout << num[n%10];
flag = 0;
}
else
cout << " " << num[n%10];
}
int main()
{
int sum = 0;
string n;
cin >> n;
for(int i=0; i<n.size(); i++)
{
sum += n[i]-'0';
}
spell(sum);
}
本文介绍了一个程序设计任务:给定一个非负整数N,计算其所有位数的和,并将该和的每一位用英文单词输出。输入为一个不超过10^100的大整数N,输出为该整数各位数字之和的英文单词形式。
493

被折叠的 条评论
为什么被折叠?



