PAT(甲级)1005. Spell It Right (20)
2017-01-22 15:06
453 查看
题目:https://www.patest.cn/contests/pat-a-practise/1005
代码:#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;
int main()
{
char str[10][10]={"zero","one","two","three","four","five","six","seven","eight","nine"};
char s[110],a[100];
int sum=0,temp;
gets(s);
int count=strlen(s);
for(int i=0;i<count;i++){
temp=s[i]-'0';
sum+=temp;
}
int k=0;
do{
a[k++]=sum%10;
sum=sum/10;
}while(sum!=0);
for(int i=k-1;i>=0;i--)
{
if(i!=0)
printf("%s ",str[a[i]]);
else
printf("%s",str[a[i]]);
}
system("pause");
}
代码:#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;
int main()
{
char str[10][10]={"zero","one","two","three","four","five","six","seven","eight","nine"};
char s[110],a[100];
int sum=0,temp;
gets(s);
int count=strlen(s);
for(int i=0;i<count;i++){
temp=s[i]-'0';
sum+=temp;
}
int k=0;
do{
a[k++]=sum%10;
sum=sum/10;
}while(sum!=0);
for(int i=k-1;i>=0;i--)
{
if(i!=0)
printf("%s ",str[a[i]]);
else
printf("%s",str[a[i]]);
}
system("pause");
}
相关文章推荐
- 1005. Spell It Right (20) PAT甲级刷题
- PAT甲级1005. Spell It Right (20)
- PAT - 甲级 - 1005. Spell It Right (20)
- PAT(甲级)-1005. Spell It Right (20)
- PAT甲级真题及训练集(15)--1005. Spell It Right (20)
- PAT 甲级 1005. Spell It Right (20) 【字符串】
- [PAT甲级]1005. Spell It Right (20)(求数字各个位上的和,英文输出)
- 【PAT甲级】1005. Spell It Right (20)
- PAT甲级.1005. Spell It Right (20)
- PAT甲级1005. Spell It Right (20)
- PAT 甲级 1005. Spell It Right (20)
- PAT甲级-1005. Spell It Right (20)各位之和
- PAT(甲级)1005. Spell It Right (20)
- PAT甲级1005.Spell It Right (20)
- PAT甲级 1005. Spell It Right (20)
- 【PAT甲级】【C++】1005. Spell It Right (20)
- [PAT-甲级]1005.Spell It Right
- 【Pat】甲级1005 - Spell It Right(STL - map)
- PAT (Advanced Level) 1005. Spell It Right (20)
- [PAT] 1005 Spell It Right (20)