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 ...
随机推荐
- CDI
CDI,JAVA用语 Java EE CDI 主要使用@Inject注解来实现依赖注入,把受管理的bean注入到由容器管理的其它资源中去.在本教程中,我们将会介绍在CDI环境下几种不同的可选策略来实现 ...
- Container&injection
容器(Container)就是组件和底层服务细节之间的接口.在web组件.企业级Bean等能够执行之前,它必须被装配为一个JavaEE模块,并部署在容器上. 在JavaEE5时代通过注解的方式注入(i ...
- python dpkt SSL 流tcp payload(从三次握手开始到application data)和证书提取
# coding: utf-8 #!/usr/bin/env python from __future__ import absolute_import from __future__ import ...
- Guava:好用的java类库 学习小记
基础功能 google guava中定义的String操作 在google guava中为字符串操作提供了很大的便利,有老牌的判断字符串是否为空字符串或者为null,用指定字符填充字符串,以及拆分合并 ...
- 理解linux下的load
我们在做Linux负载计算的时候,我们需要了解负载的几个概念 1)Linux负载是什么 2)Linux负载怎么计算 3)如何区分目前负载是“好”还是“坏” 4)什么时候应该注意哪些不正常的值 1) ...
- JAVA概率实现--一篇最常见、最通用解决方案
日常场景:某活动抽奖,控制各等奖的出现概率 比如控制A(中奖率):20%:B(获得优惠券率):30%:C(谢谢参与率):50% 下面以封装好在main()函数里,上代码(记得导入相应的包): publ ...
- ui自动化:python+appium----环境搭建
前言: appium可以说是app最火的一个自动化框架,它的主要优势是支持android和ios,另外脚本支持java和python.以下为python+appium的安装教程... 环境准备... ...
- cat语法
语法格式 cat [-AbeEnstTuv] [--help] [--version] fileName 参数说明: -n 或 --number:由 1 开始对所有输出的行数编号. -b 或 --nu ...
- php查询快递的类
<?php/** * Express.class.php 快递查询类 * * @copyright widuu * @license ...
- 自动化测试-11.selenium的下拉框处理类Select
前言 最近由于工作原因,更新慢了一点,今天终于抽出一点时间给大家继续更新selenium系列,学习的脚本不能停止,希望小伙伴能多多支持. 本篇以百度设置下拉选项框为案例,详细介绍select下拉框相关 ...