1005. Spell It Right
2015-10-10 20:19
288 查看
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:
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<string> #include<sstream> #include<stdio.h> using namespace std; int main() { string s; int count = 0; cin>>s; string str[10] = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"}; int sum = 0; for(int i = 0; i < s.length(); i ++) sum = sum + s[i] - '0'; ostringstream oss; oss<<sum; s = oss.str(); for(int i = 0; i < s.length(); i ++) if(i == 0) cout<<str[s[i]-'0']; else cout<<" "<<str[s[i]-'0']; cout<<endl; return 0; }
[/code]
相关文章推荐
- CustomEditor 自定义预览窗
- xaml控件样式大全(太有用了)C#
- 哪里有免费的PPT素材模板下载?哪里有免费的高大上的商务PPT模板下载?哪里有免费的PPT图标素材下载?哪里有免费的PPT教程下载?哪有高质量的PPT模板下载?
- Google hack 之 查询语法
- 模拟三次密码输入
- Android Fragment 组件学习
- 大话设计模式笔记 享元模式
- fragment Activity之间传值的方法 之------------接口回调
- BZOJ 1515 [POI2006]Lis-The Postman (挖坑)欧拉回路+重构
- Java声明和定义
- 抱怨多了,也就被嫌弃了
- 输出“welcome to bit!”
- Hive Tips
- BZOJ2763飞行路线|二维SPFA
- 网络参数与配置文件
- STL中map与hash_map容器的选择
- 大数据资料分享
- C++学习笔记8——迭代器(iterator)
- multipart/form-data请求与文件上传
- mybatis01