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.
简单死了,但是我第四个测试点老是过不去!!!!
9的英文是 nine!!!!!
代码:
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
string kk[10]={"zero","one","two","three","four","five","six","seven","eight","nine"};
int main()
{
string num;
cin>>num;
long long sum=0;
for(int i=0;i<num.size();i++)
{
sum+=num[i]-'0';
}
int temp=0;
if(sum==0)
{
cout<<"zero";
}
else
{
string now[1000];
int tk=0;
while(sum)
{
now[tk++]+=kk[sum%10];
sum/=10;
}
for(int i=tk-1;i>=0;i--)
{
cout<<now[i];
if(i!=0)
{
cout<<" ";
}
}
}
return 0;
}