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 ...
随机推荐
- python基础之 数据格式化
%还是format 皇城PK Python中格式化字符串目前有两种阵营:%和format,我们应该选择哪种呢? 自从Python2.6引入了format这个格式化字符串的方法之后,我认为%还是form ...
- 测试String——StringBuffer——StringBulider的速度
package comnf147Package; import java.util.ArrayList; import java.util.List; public class String_Test ...
- java 强弱软虚 四种引用,以及用到的场景
1.利用软引用和弱引用解决OOM问题:用一个HashMap来保存图片的路径和相应图片对象关联的软引用之间的映射关系,在内存不足时,JVM会自动回收这些缓存图片对象所占用的空间,从而有效地避免了OOM的 ...
- 在SOUI3.0中使用数值动画
上一篇介绍了插值动画,插值动画是直接作用于窗口对象的. 数值动画则可以作用于任何对象. SOUI内置了3种数值类型的动画,分别是SIntAnimator, SFloatAnimator, SColor ...
- STL标准库-容器-set与map
STL标准库-容器-set与multiset C++的set https://www.cnblogs.com/LearningTheLoad/p/7456024.html STL标准库-容器-map和 ...
- python - property 属性函数
Python中有一个被称为属性函数(property)的小概念,它可以做一些有用的事情.在这篇文章中,我们将看到如何能做以下几点: 将类方法转换为只读属性 重新实现一个属性的setter和getter ...
- 设计模式(5): vue 不监听绑定的变量
概述 最近最近做项目的时候总会思考一些大的应用设计模式相关的问题,我把自己的思考记录下来,供以后开发时参考,相信对其他人也有用. 绑定变量 一般情况下,如果我们需要在组件中使用某个变量,会这么使用: ...
- 服务器控件调用JS函数
是服务器端控件,不能在JS里直接调用,但可以在aspx.cs 里写方法可以调用JS函数,比如JS方法名称是check(), function check() { alert(document.ge ...
- Spring 之 IOC ,DI 理论
本文是依照极客学院java<Spring之IOC>章节学习的心得.随笔记录 浅谈IOC:(Inversion of Control, 控制反转) Spring 核心容器,贯穿始终.所谓IO ...
- 【ABAP系列】SAP 面试 ABAPer的一些感想
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP 面试 ABAPer的一些 ...