PAT 甲级 A1005 (2019/02/10)

Posted zjsaipplp

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PAT 甲级 A1005 (2019/02/10)相关的知识,希望对你有一定的参考价值。

 1 #include<cstdio>
 2 #include<cstring>
 3 char str[10][6] = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
 4 int main(){
 5     int i = 0, sum = 0, digit[10];
 6     char number[111];
 7     scanf("%s",number);
 8     int n = strlen(number);
 9     for(int i = 0; i < n; i++)
10         sum += number[i] - 0;
11     if(number[0] == 0)
12         printf("zero"); 
13     else{
14         while(sum){
15             digit[i++] = sum % 10;
16             sum /= 10;
17         }
18         for(int j = i-1; j >= 0; j--){
19             if(j != i-1)    
20                 printf(" ");
21             printf("%s",str[digit[j]]);
22         }
23     }
24     return 0;
25 } 

 

以上是关于PAT 甲级 A1005 (2019/02/10)的主要内容,如果未能解决你的问题,请参考以下文章

PAT 甲级 A1035 (2019/02/10)

PAT 甲级 A1001 (2019/02/10)

PAT 甲级 A1001 (2019/02/10)

PAT 甲级 A1073 (2019/02/10) NULL(18/20)

PAT A1005 Spell It Right

pat甲级75分在啥水平