PAT Advanced 1005 Spell It Right (20 分)
2024-09-05 19:39:02
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 (≤).
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<stack>
using namespace std;
int main() {
string s;
cin>>s;
stack<int> sta;
int sum=,tmp;
for(int i=;i<s.length();i++){
sum+=(s[i]-'');
}
while(sum!=){
sta.push(sum%);
sum/=;
}
if(sta.empty()) cout<<"zero";
while(!sta.empty()){
tmp=sta.top();
sta.pop();
switch(tmp){
case :cout<<"zero";break;
case :cout<<"one";break;
case :cout<<"two";break;
case :cout<<"three";break;
case :cout<<"four";break;
case :cout<<"five";break;
case :cout<<"six";break;
case :cout<<"seven";break;
case :cout<<"eight";break;
case :cout<<"nine";break;
case :cout<<"ten";break;
}
if(sta.size()!=) cout<<" ";
}
system("pause");
return ;
}
最新文章
- 8. apache服务实验笔记
- 概率DP light oj 1038
- linux优先级、性能监控指令
- 【高德地图开发4】---增加覆盖物setMapTextZIndex
- noip2007提高组题解
- 简易ORM(基于注解)
- android开发常用组件(库)推荐
- LintCode- 删除排序数组中的重复数字
- net搭建热插拔式web框架(沙箱的构建)
- LINUX6安装Oracle10g无法启动安装界面解决
- Python 命令模式和交互模式
- .net 4.0 中的特性总结(四):Tuple类型
- Linux 下文件
- html随笔CSS(*^__^*)
- FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. com/mongodb/util/JSON
- SpringMVC之ajax+select下拉框交互常用方式
- 珍藏40个android应用源码分享
- Spring Cloud 学习网址
- Java8 (Function,Consumer,Predicate,Supplier)详解
- 在Linux中安装Oracle(较详细图解)
热门文章
- [LeetCode]-algorithms-Longest Palindromic Substring
- 20175201张驰 实验四 Android 开发
- 洛谷P2023 [AHOI2009]维护序列(线段树区间更新,区间查询)
- 修改web项目发布路径
- Nova 的高性能虚拟机支撑
- C# 获取当前网页HTML
- cobbler批量安装系统
- mysql安装及相关配置
- 5.使用github脚本LAZY----几个最好的发行版----自定义终端----基本命令
- python调用java所有代码都要放在jvm开启的时候调用,否则报错: No matching overloads found for in find. at native\common\jp_method.cpp:127