首页 > 其他分享 >1005. Spell It Right (20)

1005. Spell It Right (20)

时间:2022-11-25 14:35:11浏览次数:60  
标签:case Right return 答案 temp Spell break ms 1005


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



评测结果

时间

结果

得分

题目

语言

用时(ms)

内存(kB)

用户

7月17日

20:29

答案正确

​20​

​1005​

​C++ (g++ 4.7.2)​

1

368

​datrilla​

测试点

测试点

结果

用时(ms)

内存(kB)

得分/满分

0

答案正确

1

232

1/1

1

答案正确

1

232

2/2

2

答案正确

1

256

3/3

3

答案正确

1

256

3/3

4

答案正确

1

236

3/3

5

答案正确

1

368

3/3

6

答案正确

1

368

3/3

7

答案正确

1

232

2/2

#include<iostream> 
#include<string>
#include<string.h>
using namespace std;
string SpellItRight(int i)
{
switch(i){
case 0:return "zero\0";
break;
case 1:return "one\0";
break;
case 2:return "two\0";
break;
case 3:return "three\0";
break;
case 4:return "four\0";
break;
case 5:return "five\0";
break;
case 6:return "six\0";
break;
case 7:return "seven\0";
break;
case 8:return "eight\0";
break;
}
return "nine\0";
}
int main()
{
int temp,len;
string ms;
char N[101];
cin>>N;
temp=0;
len=strlen(N);
for(int i=0;i<len;i++)
{
temp+=N[i]-'0';
}
ms=SpellItRight(temp%10);
temp/=10;
while(temp>0)
{
ms=" "+ms;
ms=SpellItRight(temp%10)+ms;
temp/=10;
}
cout<<ms<<endl;
return 0;
}


标签:case,Right,return,答案,temp,Spell,break,ms,1005
From: https://blog.51cto.com/datrilla/5886667

相关文章