其他分享
首页 > 其他分享> > PAT 1005 Spell It Right 水题

PAT 1005 Spell It Right 水题

作者:互联网

//1005
char a[105];
char* num[] = {"zero","one","two","three","four","five","six","seven","eight","nine"};
stack<char*> out;
int main(){

    while(scanf("%s",a)!=EOF){
        int sum=0;
        for(int i=0;i<strlen(a);i++){
            sum+=a[i]-'0';
        }
        if(sum==0) out.push(num[sum]);
        while(sum){
            out.push(num[sum%10]);
            sum/=10;
        }
        while(!out.empty()){
            printf("%s",out.top());
            out.pop();
            if(!out.empty()) printf(" ");
        }
        printf("\n");
    }
    return 0;
}

wizardOfCode 发布了66 篇原创文章 · 获赞 4 · 访问量 4120 私信 关注

标签:私信,seven,Right,int,Spell,char,文章,1005
来源: https://blog.csdn.net/qq_31650113/article/details/104590970