PAT 甲级 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 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
注意:题中有一个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 ;
}
PAT 甲级 1005 Spell It Right (20 分)的更多相关文章
- 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) 【字符串】
题目链接 https://www.patest.cn/contests/pat-a-practise/1005 思路 因为 n <= 10^100 所以 要用字符串读入 但是 100 * 100 ...
- Day 006:PAT练习--1005 Spell It Right (20 分)
上星期一直在写报告乱七八糟的,从今天开始不刷乙级的了,还是多刷甲级进步来得快一点! 显而易见,该题的关键在于将输入之和的每一位从高到低输出,这里我们发现题意中的输入数的范围为0-10^100,显然我们 ...
- 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 e ...
- 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甲级:1152 Google Recruitment (20分)
PAT甲级:1152 Google Recruitment (20分) 题干 In July 2004, Google posted on a giant billboard along Highwa ...
- 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 甲级 1041 Be Unique (20 分)
1041 Be Unique (20 分) Being unique is so important to people on Mars that even their lottery is desi ...
随机推荐
- ECharts4简单入门
参考:echarts3 使用总结 echarts3使用总结2 最近在leader的忽悠下开始接触echarts,的确被它丰富的图表样式吸引了,现写入门教程如下: 官方入门教程参考: EChart ...
- Vue(三) v-bind 及 class 与 style 绑定
DOM 元素经常会动态绑定一些 class 类名 或 style 样式,现在介绍使用 v-bind 指令来绑定 class 和 style 的多种方法. 了解 v-bind 指令 在之前已经介绍了指令 ...
- 告诉你们!我是怎么与Linux系统接触的!
最开始接触Linux是在15年来北京后,刚来北京机缘巧合,从事了实施工程师的工作.实施工作是一个面很广的工作.业务.技术.沟通等等方方面面的.技术一直是我是的短板.刚开始,公司在要在阿里云上部署APP ...
- web app、hybrid app和native app区别
- Android开发 ---代码创建选项菜单、隐藏菜单项、菜单的生命周期,菜单按钮图标设置、搜索框、xml中设置子菜单
1.activity_main.xml 描述: 定义了一个按钮 <?xml version="1.0" encoding="utf-8"?> < ...
- raid的一些简单知识
日一.RAID定义RAID(Redundant Array of Independent Disk 独立冗余磁盘阵列)技术是加州大学伯克利分校1987年提出,最初是为了组合小的廉价磁盘来代替大的昂贵磁 ...
- PyCharm基本用法
1.修改字体 在file->settings下进行修改如下图: 2 修改颜色背景 在file->settings下修改,如图: 3连接git 点击file->settings,选择版 ...
- Java语法基础学习DayEighteen(常用类)
一.String类 1.特点 String代表不可变的字符序列,底层用char[]存放. String是final的. 2.内存解析 3.常用方法 int length() char charAt(i ...
- JavaScript之循环
我是昨天的小尾巴...https://blog.csdn.net/weixin_42217154/article/details/81182817 3.2 循环结构 循环结构是指在程序中需要反复执行某 ...
- python自学第10天,生成器
列表生成式 print([i*2 for i in range(10)])#这就是列表生成式 #相当于下面的代码 a=[] for i in range(10): a.append(i*2) prin ...