1005 Spell It Right (20)

 1 #include <string>
 2 #include <sstream>
 3 #include <iostream>
 4 using namespace std;
 5
 6 int main()
 7 {
 8     string str;
 9     char num[10][6]={"zero","one","two","three","four","five","six","seven","eight","nine"};
10     while(getline(cin,str))
11     {
12         int sum=0;
13         for(int i=0;i<str.length();i++)
14             sum+=str[i]-‘0‘;
15         string result;
16         stringstream ss;
17         ss<<sum;
18         ss>>result;
19
20         for(int i=0;i<result.length();i++)
21         {
22             if(i==0) printf("%s",num[ result[i]-‘0‘ ]);
23             else  printf(" %s",num[ result[i]-‘0‘ ]);
24             //printf("%c",result[i]);
25         }
26         printf("\n");
27     }
28     return 0;
29 }
时间: 2024-11-08 15:50:53

1005 Spell It Right (20)的相关文章

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

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)(20 分)

1005 Spell It Right (20)(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 l

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 li

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 which contains an N (<= 101

PAT甲题题解-1005. Spell It Right (20)-数位求和,水

把每个位上的数字求和sum,然后以英文单词的形式输出sum的每个位 #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <vector> using namespace std; /* 把每个位上的数字求和sum,然后以英文单词的形式输出sum的每个位 水 */ char word[10][20]={"zero&qu

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&q

PAT:1005. Spell It Right (20) AC

#include<stdio.h> #include<string.h> char alp[10][10]={"zero","one","two","three","four","five","six","seven","eight","nine"}; char str[1200];