1005. Spell It Right (20)
2018-02-09 21:37
288 查看
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:
12345Sample Output:
one five题目大意:
给定一个非负整数N,你的任务是计算出N的所有数字之和,并用英文输出和的每一个数位上的数字。
输入规格:
每个输入文件包含一个测试用例。每一个用例占用包含N(<=10的100次方)的行。
输出规范:
对于每个测试用例,在一行中用英文输出和的每一个数位上的数字。两个连续的单词之间必须有一个空格,但是在一行的末尾没有多余的空格。 #include<bits/stdc++.h>
int main()
{
char num[101],arr[101];
int sum=0,m,i,j;
scanf("%s",num);
for(i=0;num[i]!='\0';i++)
{
sum+=num[i]-'0';
}
if(sum==0)
{
printf("zero");
}
else
{
for(i=0;sum!=0;i++)
{
arr[i]=sum%10;
sum/=10;
}
for(j=i-1;j>=0;j--)
{
if(j!=i-1)
printf(" ");
switch(arr[j])
{
case 0:printf("zero");
break;
case 1:printf("one");
break;
case 2:printf("two");
break;
case 3:printf("three");
break;
case 4:printf("four");
break;
case 5:printf("five");
break;
case 6:printf("six");
break;
case 7:printf("seven");
break;
case 8:printf("eight");
break;
case 9:printf("nine");
break;
}
}
}
return 0;
}
相关文章推荐
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- PAT1005. Spell It Right (20)
- PAT (Advanced) 1005. Spell It Right (20)
- PAT 1005. Spell It Right(20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)(C++)
- PAT:A1005. Spell It Right (20/20)
- 【PAT甲级】1005. Spell It Right (20)
- 1005. Spell It Right (20)
- PAT 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- PAT甲级-1005. Spell It Right (20)各位之和
- 1005. Spell It Right (20)
- PAT 甲 1005. Spell It Right (20)
- PAT甲级.1005. Spell It Right (20)
- (PAT)1005. Spell It Right (20)
- 1005. Spell It Right (20)