1005. Spell It Right (20)
来源:互联网 发布:杭州龙席网络盈店通 编辑:程序博客网 时间:2024/05/29 11: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
参考代码:
#include <iostream>//#includeusing namespace std;int main(){ string output[] = {"zero","one","two","three","four","five","six","seven","eight","nine"}; string n; cin>>n; char temp; int sum = 0; for(int i=0;i<n.length();i++){ temp = n.at(i); sum+=(temp-48); } int end[100]; int flag=0; if(sum==0){ cout<<output[0]; }else{ while(sum!=0){ end[flag++]=sum%10; sum=sum/10; } for(int i=flag-1;i>0;i--){ cout<<output[end[i]]<<" "; } cout<<output[end[0]]; } 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)
- 面向切面编程(AOP)的理解
- ModelSim手动配置方法
- 1003. Emergency (25)
- linux io模型
- ZOJ-2892
- 1005. Spell It Right (20)
- Cracking the coding interview--Q2.2
- Fragment不能再构造方法中调用getActivity()
- ThinkPHP 原生SQL查询
- iOS Create an CGImageSource
- Python学习系列六:函数的参数对应
- IOS中系统唯一标识ID
- block代码块
- android通过反射代替R来获取控件对象