PAT甲级——A1005 Spell It Right
题目描述
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.
输入描述:
Each input file contains one test case. Each case occupies one line which contains an N (<= 10100).
输出描述:
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.
输入例子:
12345
输出例子:
one five 太简单了。。。。
#include <iostream>
#include <string>
#include <vector> using namespace std; int main()
{
vector<string>words = { "zero","one","two","three","four","five","six","seven","eight","nine","ten" };
string num;//不能用数字类型存储,会导致溢出的
cin >> num;
int sum = ;
for (auto a : num)
sum += a - '';
num = to_string(sum);
cout << words[num[] - ''];
for (int i = ; i < num.length(); ++i)
cout << " " << words[num[i] - ''];
cout << endl;
return ;
}
PAT甲级——A1005 Spell It Right的更多相关文章
- 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 th ...
 - 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
		
https://pintia.cn/problem-sets/994805342720868352/problems/994805519074574336 Given a non-negative i ...
 - PAT 甲级 1005. Spell It Right (20) 【字符串】
		
题目链接 https://www.patest.cn/contests/pat-a-practise/1005 思路 因为 n <= 10^100 所以 要用字符串读入 但是 100 * 100 ...
 - PAT甲级题解(慢慢刷中)
		
博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6102219.html特别不喜欢那些随便转载别人的原创文章又不给 ...
 - PAT甲级代码仓库
		
大道至简,知易行难.希望能够坚持刷题. PAT甲级真题题库,附上我的代码. Label Title Score Code Level 1001 A+B Format 20 1001 * 1002 A+ ...
 - PAT甲级题解分类byZlc
		
专题一 字符串处理 A1001 Format(20) #include<cstdio> int main () { ]; int a,b,sum; scanf ("%d %d& ...
 - PAT甲级1131. Subway Map
		
PAT甲级1131. Subway Map 题意: 在大城市,地铁系统对访客总是看起来很复杂.给你一些感觉,下图显示了北京地铁的地图.现在你应该帮助人们掌握你的电脑技能!鉴于您的用户的起始位置,您的任 ...
 - PAT甲级1127. ZigZagging on a Tree
		
PAT甲级1127. ZigZagging on a Tree 题意: 假设二叉树中的所有键都是不同的正整数.一个唯一的二叉树可以通过给定的一对后序和顺序遍历序列来确定.这是一个简单的标准程序,可以按 ...
 
随机推荐
- 转: PHP中this,self,parent的区别
			
{一}PHP中this,self,parent的区别之一this篇 面向对象编程(OOP,Object OrientedProgramming)现已经成为编程人员的一项基本技能.利用OOP的思想进行P ...
 - JS对象 返回星期方法 getDay() 返回星期,返回的是0-6的数字,0 表示星期天。如果要返回相对应“星期”,通过数组完成
			
返回星期方法 getDay() 返回星期,返回的是0-6的数字,0 表示星期天.如果要返回相对应"星期",通过数组完成,代码如下: <script type="te ...
 - cookie与token对比(转)
			
1.cookie(储存在用户本地终端上的数据( 为了辨别用户身份.进行 session 跟踪)) HTTP协议本身是无状态的,所以需要一个标志来对用户身份进行验证 用户登录成功后,会在服务器存一个se ...
 - colormap 参数及对应色卡
			
[参考] [1]matlab帮助文档
 - 实用的 atom 插件
			
推荐几款我喜欢的Atom插件 时间 2017-05-05 09:00:00 Hi Linux 原文 http://www.hi-linux.com/posts/28459.html 主题 Atom ...
 - Java-Maven-pom.xml-porject-parent:parent
			
ylbtech-Java-Maven-pom.xml-porject-parent:parent 1.返回顶部 1.Inherit defaults from Spring Boot <!-- ...
 - mysql重点,表查询操作和多表查询
			
表单查询 1. 完整的查询语句语法 select distinct(* or 字段名 or 四则运算 )from 表名 where 条件 group by 条件 having 条件 order by ...
 - 2017/8/4 SCJP学习
			
2 Object Orientation . . . . . . . . . . . . . . . . . . . . . . . . . 85 Encapsulation (Exam Object ...
 - day19_生成器
			
20180730 初次上传 20180731 更新,4.列表生成式,以及部分注释 #!/usr/bin/env python # -*- coding:utf-8 -*- # ************ ...
 - HUD1686-Oulipo-kmp模板题/哈希模板题
			
The French author Georges Perec (1936–1982) once wrote a book, La disparition, without the letter 'e ...