PAT 甲级 A1005 (2019/02/10)

Posted zjsaipplp

tags:

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

#include<cstdio>
#include<cstring>
char str[10][6] = {
    "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"
};
int main(){
    int i = 0, sum = 0, digit[10];
    char number[111];
    scanf("%s",number);
    int n = strlen(number);
    for(int i = 0; i < n; i++)
        sum += number[i] - '0';
    if(number[0] == '0')
        printf("zero"); 
    else{
        while(sum){
            digit[i++] = sum % 10;
            sum /= 10;
        }
        for(int j = i-1; j >= 0; j--){
            if(j != i-1)    
                printf(" ");
            printf("%s",str[digit[j]]);
        }
    }
    return 0;
} 

以上是关于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分在啥水平