PAT甲级字符串处理1005 Spell It Right
2019-01-23 15:51
232 查看
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).
Output Specification:
For each test case, output in one line the digits of the sum in English words. There must be one space between two consecutive words, but no extra space at the end of a line.
Sample Input:
[code]12345
Sample Output:
[code]one five
[code]#include<bits/stdc++.h> #include<math.h> using namespace std; char num[10][10]= {"zero","one","two","three","four","five","six","seven","eight","nine"}; int main() { char s[110]; int sum[5],c=0,i; scanf("%s",s); for(i=0; s[i]!='\0'; i++) c += s[i]-'0'; if(c==0)sum[0]=0; else { for(i=0; c>0; i++) { sum[i] = c%10; c /= 10; } for(i=i-1; i>0; i--) printf("%s ",num[sum[i]]); } printf("%s",num[sum[0]]); }
相关文章推荐
- 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
- PAT甲级1005. Spell It Right
- 【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(STL - map)
- 1005. Spell It Right (20) PAT甲级刷题
- PAT甲级真题及训练集(15)--1005. Spell It Right (20)
- pat甲级1005-Spell It Right
- 【PAT甲级】【C++】1005. Spell It Right (20)
- [PAT-甲级]1005.Spell It Right
- PAT(甲级)1005. Spell It Right (20)
- PAT甲级1005. Spell It Right (20)