###### 1005. Spell It Right (20)

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

AC代码：

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char number[10][10] = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
char result[10][10] = {0};
int main(int argc, char* argv[])
{
int sum = 0, i;
char num[1000] = {0};
scanf("%s", num);
for(i = 0; i < strlen(num); i++)
{
sum += num[i] - '0';
}
if(sum == 0)
{
printf("zero\n");
}
else{
i = 0;
while(sum){
strcpy(result[i++], number[sum%10]);
sum = sum / 10;
}
for(i = i - 1;i >= 0 ; i--)
{
if(0 == i)
printf("%s\n", result[0]);
else
printf("%s ", result[i]);
}
}
system("pause");
return 0;
}

#### 【c++】PAT (Advanced Level) 1005. Spell It Right (20)

2014-02-22 14:58:00

#### 1005. Spell It Right (20)解题思路

2016-06-25 06:40:15

#### PAT - 甲级 - 1005. Spell It Right (20)

2016-07-02 20:35:43

#### PAT A1005. Spell It Right

2017-04-06 19:06:54

#### PAT (Advanced Level) 1005. Spell It Right (20)

2017-03-09 00:09:02

#### 1005. Spell It Right(20)

2018-05-04 23:33:53

#### 1005. Spell It Right (20)（C++)

2018-02-26 13:38:12

#### （PAT）1005. Spell It Right (20)

2014-01-08 22:40:55

#### PAT-A 1005. Spell It Right (20)

2017-02-22 22:35:29

#### PAT 1005. Spell It Right (20)

2014-02-25 18:24:49

## 不良信息举报

1005. Spell It Right (20)