1005. Spell It Right (20)
2016-02-17 09:40
337 查看
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:
12345
Sample Output:
one five
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:
12345
Sample Output:
one five
#include<iostream> #include<vector> #include<string> using namespace std; string num[10]={"zero","one","two","three","four","five","six","seven","eight","nine"}; int main(){ char t=' '; int n=0; while(1){ t=getchar(); if(t=='\n') break; n+=t-'0'; } vector <int> out; if(n==0) out.push_back(0); while(n!=0){ out.push_back(n%10); n/=10; } cout<<num[out[out.size()-1]]; for(int i=out.size()-2;i>=0;i--){ cout<<" "<<num[out[i]]; } cout<<endl; return 0; }
相关文章推荐
- 通过 itms:services://? 在线安装ipa ,跨过appstore
- linux学习相对路径与绝对路径
- iOS开源现成的有用的东西,方便以后找
- linux下如何查看SVN的用户密码
- Stanford机器学习---第三讲. 逻辑回归和过拟合问题的解决 logistic Regression & Regularization
- 动态调用函数:再解apply和call
- swift初见
- 基于注解的SpringMVC简单介绍
- poj2299 Ultra-QuickSort 二叉排序树或树状数组
- MODBUS RTU协议中浮点数是如何存储,读到浮点数寄存器的数值如何转换成所需的浮点数
- 【NOIP2011】计算系数
- 剖析微软Hyper-V的最佳部署方式
- DBA的技能图谱
- 关于PackageInfo、ApplicationInfo、ActivityInfo、ResolveInfo四种信息类
- BZOJ2190: [SDOI2008]仪仗队
- Iptables 指南 1.1.19
- Android使用shape设置虚线、圆角、渐变
- jQuery实例-记住登录信息
- Python 输入输出
- oracle的批量插入