PAT Advanced 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 (≤).
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 ;
}
PAT Advanced 1005 Spell It Right (20 分)的更多相关文章
- Day 006:PAT练习--1005 Spell It Right (20 分)
上星期一直在写报告乱七八糟的,从今天开始不刷乙级的了,还是多刷甲级进步来得快一点! 显而易见,该题的关键在于将输入之和的每一位从高到低输出,这里我们发现题意中的输入数的范围为0-10^100,显然我们 ...
- PAT (Advanced Level) Practice 1005 Spell It Right (20 分) 凌宸1642
PAT (Advanced Level) Practice 1005 Spell It Right (20 分) 凌宸1642 题目描述: Given a non-negative integer N ...
- 1005 Spell It Right (20分)
1005 Spell It Right (20分) 题目: Given a non-negative integer N, your task is to compute the sum of all ...
- PAT (Advanced Level) Practice 1035 Password (20 分) 凌宸1642
PAT (Advanced Level) Practice 1035 Password (20 分) 凌宸1642 题目描述: To prepare for PAT, the judge someti ...
- PAT (Advanced Level) Practice 1008 Elevator (20 分) 凌宸1642
PAT (Advanced Level) Practice 1008 Elevator (20 分) 凌宸1642 题目描述: The highest building in our city has ...
- PAT 甲级 1005 Spell It Right (20)(代码)
1005 Spell It Right (20)(20 分) Given a non-negative integer N, your task is to compute the sum of al ...
- PAT 甲 1005. Spell It Right (20) 2016-09-09 22:53 42人阅读 评论(0) 收藏
1005. Spell It Right (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Given ...
- PAT (Advanced Level) Practice 1005 Spell It Right (20 分) (switch)
Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output e ...
- 【PAT甲级】1005 Spell It Right (20 分)
题意: 给出一个非零整数N(<=10^100),计算每位之和并用英文输出. AAAAAccepted code: #include<bits/stdc++.h> using name ...
随机推荐
- centos7 安装 Spring Tools 4 for Eclipse
1.spring 官网下载 https://spring.io/tools 2.解压 tar -zxvf spring-tool-suite--.RELEASE-e4.11.0-linux.gtk.x ...
- vue php实战项目开发(一)
说在前面 项目开发过程中一直在学习,所以记录的过程可能比较乱,打算前台使用vue,后台使用php开发手机端的项目,这里记录遇到的问题和学习的过程 phpstudy环境下搭建虚拟域名,并开启URL重写 ...
- yii 1.1简单文件缓存
缓存组件配置在config\main.php文件,简单配置下文件缓存 'components'=>array( 'cache' => array( 'class' => 'syste ...
- jieba(结巴)常用方法
python jieba库的基本使用 第一步:先安装jieba库 输入命令:pip install jieba jieba库常用函数: jieba库分词的三种模式: 1.精准模式:把文本精准地分开 ...
- Linux下用jar命令更新jar包文件
jar -uvf SDK_Web_ChartReport.war view/global/header.jsp echo '样式文件替换进包中' 查看jar包中的文件: jar -tvf SDK ...
- 杂项-桌面应用程序:Windows Live Writer(WLW)
ylbtech-杂项-桌面应用程序:Windows Live Writer(WLW) Windowslive Writer 即(WLW) 是一个免费的桌面应用程序,您可以使用它轻松发布丰富的内容到您的 ...
- linux iptables相关
iptables -A INPUT -p udp --dport 90 -j ACCEPT iptables -A INPUT -p tcp -m state --state ESTABLISHED ...
- linux防火墙iptables简单介绍
--append -A chain Append to chain --delete -D chain Delete matching rule from chain ...
- 4.站点克隆wget----隐写术图片----backbox linux
站点克隆wget sudo bash cd Desktop/Cloned wget -h clear wget -mk https://help.ubuntu.com/ 隐写术图片 想想朋友圈的图片 ...
- python+selenium操作cookie
WebDriver提供了操作Cookie的相关方法,可以读取.添加和删除cookie信息. WebDriver操作cookie的方法: get_cookies(): 获得所有cookie信息. get ...