首页 > 其他 > 详细

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

时间:2016-05-15 21:39:54      阅读:241      评论:0      收藏:0      [点我收藏+]

简单题。

#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<vector>
using namespace std;

const int maxn=100+10;
char s[maxn];
int tmp[maxn],tot;
char ans[15][7]={
    "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"
};

int main()
{
    scanf("%s",s);
    int num=0; for(int i=0;s[i];i++) num=num+s[i]-0;
    if(num==0)
    {
        printf("zero\n");
    }
    else{
        tot=0; while(num) tmp[tot++]=num%10,num=num/10;
        for(int i=tot-1;i>=0;i--)
        {
            printf("%s",ans[tmp[i]]);
            if(i>0) printf(" ");
            else printf("\n");
        }
    }
    return 0;
}

 

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

原文:http://www.cnblogs.com/zufezzt/p/5495993.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!