1005 Spell It Right (20 分)

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 (≤10​100​​).

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

注意:题中有一个case是0

 #include<iostream>
#include<string>
#include<stack> using namespace std; string numEnglish[] = {"zero","one","two","three","four","five","six","seven","eight","nine"}; int main()
{
string str;
int sum = ;
stack<int> s; getline(cin,str); for(int i=;i<str.size();++i)
sum += str[i]-; if(sum == )
cout<<"zero"<<endl;
else
{
while(sum)
{
s.push(sum%);
sum /= ;
} cout<<numEnglish[s.top()];
s.pop(); while(!s.empty())
{
cout << " " << numEnglish[s.top()];
s.pop();
}
} return ;
}
 

最新文章

  1. 《Benign and maligenant breast tumors classification based on region growing and CNN segmentation》翻译阅读与理解
  2. 1.NSThread
  3. [iOS]如何删除工程里面用cocoapods导入的第三方库
  4. 苹果操作系统Mac OS X
  5. GridView、Repeater获取当前行号
  6. poj3723 MST好题 kruskal
  7. hihocoder——1041国庆出游(搜索)
  8. samba及其基本应用
  9. Java函数式编程和lambda表达式
  10. EditPlus配置GCC
  11. C# [IPA]IOS In App Purchase(内购)验证(asp.net 版本)
  12. Git学习笔记4
  13. Java设计模式(八)----代理模式
  14. phalcon无限重定向
  15. 自定义标签+阻尼动画+圆角图片+titleBar随滑动渐隐和显示
  16. apt-get install 和 pip install的区别
  17. logback 发送邮件的类.
  18. tomcat报错-----》Unable to open debugger port IDEA Unable to open debugger port
  19. 一个IT中专生在深圳的9年辛酸经历
  20. 前端构建工具gulpjs的使用介绍及技巧 (转)

热门文章

  1. JavaScript基础三
  2. 锯齿状优惠券css绘制
  3. Python3+mitmproxy安装使用教程(Windows)
  4. Eclipse 手动增加linker library
  5. spoj mgame
  6. Python基础10_函数
  7. pip3 install mysqlclient 报错 “/bin/sh: 1: mysql_config: not found”的解决方法
  8. ORA-00847: MEMORY_TARGET/MEMORY_MAX_TARGET and LOCK_SGA cannot be set together
  9. Dubbo透传traceId/logid的一种思路
  10. 复习-java-001