PAT A1005. Spell It Right (20)
来源:互联网 发布:dos编译java文件 编辑:程序博客网 时间:2024/06/11 11:28
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:12345Sample Output:
one five
#include <cstdio>#include <algorithm>#include <cmath>#include <cstring>#define Max 100001using namespace std;int main(){char N[11][11]={"zero","one","two","three","four","five","six","seven","eight","nine"};char n[111];int sum=0,m[111],k=0;scanf("%s",n);for(int i=0;i<strlen(n);i++){sum+=n[i]-'0';}if(sum==0) printf("zero\n");else {while(sum>0){m[k++]=sum%10;sum/=10;}for(int i=k-1;i>=0;i--){printf("%s",N[m[i]]);if(i==0) printf("\n");else printf(" ");}}system("pause");return 0;}
0 0
- PAT:A1005. Spell It Right (20/20)
- 【PAT】 A1005. Spell It Right (20)
- PAT---A1005. Spell It Right (20)
- PAT A1005. Spell It Right (20)
- PAT A1005 Spell It Right(20)
- PAT A1005 Spell It Right
- PAT A1005. Spell It Right
- a1005. Spell It Right (20)
- A1005. Spell It Right (20)
- A1005.Spell It Right(20)
- PAT-A1005. Spell It Right (20)(模拟)
- (PAT)1005. Spell It Right (20)
- PAT 1005. Spell It Right (20)
- PAT: 1005. Spell It Right (20)
- PAT A 1005. Spell It Right (20)
- PAT 1005. Spell It Right (20)
- [PAT]1005. Spell It Right (20)
- PAT 1005. Spell It Right (20)
- 理解java的三大特性之多态
- linux 系统下使用socket进行本地进程间通信
- java集合梳理
- poj 3007 Organize Your Train part II(map)
- 归并排序
- PAT A1005. Spell It Right (20)
- POJ 3087 Shuffle'm Up (模拟)
- jquery ajax 二级联动
- React Native之组件请求网络数据
- Nginx负载均衡与高可用的实现
- 理解java的三大特性之继承
- python生成随机函数
- 题目1196:成绩排序
- java 中的多态