1005. Spell It Right (20)
来源:互联网 发布:mac中文解压软件 编辑:程序博客网 时间:2024/06/10 15:12
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
。。。。。。。。。。。。。。。。。。改了半天才发现是four拼错了
#include<iostream>#include<cstring>#include<cstdio>#include<queue>#include<stack>#include<algorithm>#include<cmath>using namespace std;int main(){char s1[12][10]={"zero","one","two","three","four","five","six","seven","eight","nine"}; int sum=0;char str[10000];cin>>str;for(int i=0;i<strlen(str);i++) sum+=str[i]-'0';int a[1000],cnt=0;while(sum){a[cnt++]=sum%10;sum/=10;}cout<<s1[a[cnt-1]];for(int i=cnt-2;i>=0;i--) cout<<" "<<s1[a[i]];return 0;}
阅读全文
0 0
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 截取字符串,含有汉字和字母,不能截半个汉字
- 用python将txt数据表转为mysql插入语句
- Unity3D ugui 界面状态控制
- 简易版WireShark实现-相关网络知识(3)
- python chr()、unichr()和ord()使用
- 1005. Spell It Right (20)
- webView项目总结(持续更新...)
- spring实战笔记2 spring mvc
- [Lesson2]Nuttx 源码编译
- C++友元类
- Android 面试题 美团
- 笛卡尔积,自然连接,外连接
- android系统属性问题
- linux学习之路