PAT-乙级 1002 写出这个数(C语言)

#include<stdio.h>
main(){
    int s=0,q[100],i=0;
    char a[10][5]={"ling","yi","er","san","si","wu","liu","qi","ba","jiu"};
    char b[100];
    scanf("%s",b);
    while(b[i]!='\0') {
        s+=b[i]-'0';
        i++;
    }
    i=0;
    while(s>0){
        q[i]=s%10;
        s/=10;
        if(s>0)
        i++;
    }
    for(;i>=0;i--)
        if(i>0)
            printf("%s ",a[q[i]]);
        else
            printf("%s",a[q[i]]);
}

发布了21 篇原创文章 · 获赞 2 · 访问量 1590

猜你喜欢

转载自blog.csdn.net/tothk/article/details/104213515
今日推荐