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
 
题目意思:对所给的一个非负整数n,求各位之和的每一位英文读音。
解题思路:先求所给n的各位之和sum,转换成string,输出对应的每一位读音即可。
 
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdio>
using namespace std;
int main()
{
int i,sum=;
string str;
string ans;
string a[]={"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
cin>>str;
for(i=; i<str.size(); i++)
{
sum+=str[i]-'';
}
ans=to_string(sum);
cout<<a[ans[]-''];//第一个读音
for(i=;i<ans.size();i++)
{
cout<<" "<<a[ans[i]-''];
}
return ;
}

最新文章

  1. 敏捷转型历程 - Sprint4 回顾会
  2. JavaScript 闭包深入浅出
  3. python--基础学习(一)开发环境搭建,体验HelloWorld
  4. SpringMVC——接收请求参数和页面传参
  5. php注意事项2
  6. 第七章 管理类型(In .net4.5) 之 使用类型
  7. 用XAML做网页!!—页头
  8. 去除 MyEclipse updating index
  9. 异常:Error resolving template &quot;xxx&quot;, template might not exist or might not be accessible...解决办法
  10. JDK源码看ArrayList和Vector的一些区别
  11. 代码:PC CSS(工作中用)
  12. poj-3279 poj-1753(二进制枚举)
  13. 03-Windows Server 2016 IIS的安装与配置
  14. Lintcode: Kth Largest Element 解题报告
  15. FZU 2105 Digits Count
  16. numpy中min函数
  17. 一位资深程序员大牛给予Java初学者的学习建议
  18. 简明 ES6 模块
  19. 【二分法】【尺取法】bzoj2348 [Baltic 2011]Plagiarism
  20. JSP常见知识点

热门文章

  1. IDC:助力转型、深入变革:中国云专业服务市场持续升温
  2. C# yield关键字
  3. 详解EMC测试国家标准GB/T 17626
  4. 小白的springboot之路(十二)、集成log4j2日志
  5. 1、看源码MVC如何实例化控制器?
  6. 设计模式-单例模式code
  7. Linux_crontab参数表示的意思
  8. Ajax之处理不同格式的JSON数据
  9. Nlog配置
  10. C++调用bat并实现传值