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

简单题。

#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;
}
时间: 2024-10-14 05:12:33

PAT (Advanced Level) 1005. Spell It Right (20)的相关文章

PAT (Advanced Level) 1001. A+B Format (20)

简单题. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> #include<cstdio> using namespace std; int a,b,tot,cnt; int u[20]; char ans[100]; int main() { while(~scanf("%d%d",&a,&b)) { a=a+b

PAT (Advanced Level) 1019. General Palindromic Number (20)

简单题. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> #include<cstdio> #include<queue> #include<vector> using namespace std; int s[10000],tot; int n,b; bool check() { for(int i=0; i<=tot

PAT (Advanced Level) 1027. Colors in Mars (20)

简单题. #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; void pri(int a) { if (a <= 9) printf("%d", a); else printf("%c", a-10+'A'); } void print(int a){ if (a >= 13

PAT (Advanced Level) 1054. The Dominant Color (20)

简单题 #include<cstdio> #include<cstring> #include<cmath> #include<vector> #include<queue> #include<algorithm> using namespace std; int a[500000]; int n,m; int main() { scanf("%d%d",&n,&m); for(int i=0;i&

PAT (Advanced Level) 1011. World Cup Betting (20)

简单题. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> #include<cstdio> using namespace std; double a[5][5],Max[5]; double ans=1; int main() { for(int i=1;i<=3;i++) for(int j=1;j<=3;j++) scanf(&qu

PTA (Advanced Level)1005.Spell It Right

Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English. Input Specification: Each input file contains one test case. Each case occupies one line which contains an N (≤10100

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

题目信息: 1005. Spell It Right (20) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English. Input Specificat

1005. Spell It Right (20) -PAT

1005. Spell It Right (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English. Input Specification: E

PAT 1005. Spell It Right (20)

1005. Spell It Right (20) Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English. Input Specification: Each input file contains one test case. Each case occupies one line w