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 题意: 假设二叉树中的所有键都是不同的正整数.一个唯一的二叉树可以通过给定的一对后序和顺序遍历序列来确定.这是一个简单的标准程序,可以按 ...
随机推荐
- 【牛客网多校第一场】A
题目链接:https://www.nowcoder.com/acm/contest/139/A 题意:大概就是给你0,1,2让你填矩阵问有多少种填法满足 a(i,j)<=a(i+1,j)以及a( ...
- Django ORM 之F、Q查询与事务
返回ORM目录 Django ORM 内容目录 一.F.Q查询 二.事务 三.only与defer 一.F.Q查询 """ Product表中的数据: 1 橡皮 2 20 ...
- 2018-10-29-微软-Tech-Summit-技术暨生态大会课程-·-基于-Roslyn-打造高性能预编译框架...
title author date CreateTime categories 微软 Tech Summit 技术暨生态大会课程 · 基于 Roslyn 打造高性能预编译框架 lindexi 2018 ...
- LINUX centos 7.2/7.3 搭建LAMP环境
首先我们先查看下centos的版本信息 #适用于所有的linux lsb_release -a #或者 cat /etc/redhat-release #又或者 rpm -q centos-relea ...
- CSIC_716_20191031【计算机的组成】
引言 什么是编程语言 语言是人与人之间的沟通介质之一,编程语言是人与机器(包括计算机)之间沟通的介质. 一个完整的计算机系统主要包括 应用程序 .操作系统 和硬件 等. 计算机三大核心 ...
- Python自学:第五章 列表解析
# -*- coding: GBK -*- squares = [value**2 for value in range(1,11)] print(squares) 输出为: [1, 4, 9, 16 ...
- C++调用python(C++)
C++源代码:python部分就是正常的python代码 #include <string.h> #include <math.h> #include "iostre ...
- csps模拟85表达式密码,电压机制,括号密码题解
题面:https://www.cnblogs.com/Juve/articles/11733280.html 表达式密码: 是个水题... #include<iostream> #incl ...
- bfs理解——hdu6386好题
用队列维护,对于每块颜色相同的相连的边进行dfs并记录即可 注意这题要用vis来标记边,不可以标记点 因为点的深度是可以随时更新的(这样的做法不满足贪心条件) #include<bits/std ...
- 基于标记的分水岭分割算法/OpenCV中距离变换
Opencv分水岭算法——watershed自动图像分割用法 OpenCV距离变换distanceTransform应用 图像分割作为图像识别的基础,在图像处理中占有重要地位,通常需要在进行图像分割算 ...