1005 Spell It Right (20)(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 (<= 10^100^).

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<string>
using namespace std;
int main() {
string str, trans[10] = { "zero","one","two","three","four","five","six","seven","eight","nine" };
char ch;
int sum=0;
while (ch=getchar()) {
if (ch == '\n')break;
sum += (ch - '0');
}
str = to_string(sum); //将和转为字符串
cout << trans[str[0] - '0']; //输出
for(int i=1;i<str.length();i++)
cout <<" " <<trans[str[i]-'0'];
return 0;
}

PAT 甲级 1005 Spell It Right (20)(代码)的更多相关文章

  1. PAT 甲级 1005. Spell It Right (20) 【字符串】

    题目链接 https://www.patest.cn/contests/pat-a-practise/1005 思路 因为 n <= 10^100 所以 要用字符串读入 但是 100 * 100 ...

  2. 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 ...

  3. 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 ...

  4. PAT 甲级 1005 Spell It Right

    https://pintia.cn/problem-sets/994805342720868352/problems/994805519074574336 Given a non-negative i ...

  5. Day 006:PAT练习--1005 Spell It Right (20 分)

    上星期一直在写报告乱七八糟的,从今天开始不刷乙级的了,还是多刷甲级进步来得快一点! 显而易见,该题的关键在于将输入之和的每一位从高到低输出,这里我们发现题意中的输入数的范围为0-10^100,显然我们 ...

  6. 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 ...

  7. 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 ...

  8. PTA 1005 Spell It Right (20)(20 分)水题

    1005 Spell It Right (20)(20 分) Given a non-negative integer N, your task is to compute the sum of al ...

  9. 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 ...

随机推荐

  1. hexo发表博文的方式

    本图片转自:简书:https://www.jianshu.com/p/a52b68794a6b 转自github:https://blog.minhow.com

  2. Swift 2.0学习笔记(Day 16)——字典集合

    Swift字典表示一种非常复杂的集合,允许按照某个键来访问元素.字典是由两部分集合构成的,一个是键(key)集合,一个是值(value)集合.键集合是不能有重复元素的,而值集合是可以重复的,键和值是成 ...

  3. Jupter 7个进阶功能

    1.  执行shell命令 Shell是一种与计算机进行文本交互的方式. 一般来讲,当你正在使用Python编译器,需要用到命令行工具的时候,要在shell和IDLE之间进行切换. 但是,如果你用的是 ...

  4. Keil 报错汇总

    main.c(6): warning:  #1-D: last line of file ends without a newline 解决:main.c 最后一行加回车就可以了. keil中文注释出 ...

  5. rect用法

    //如果创建一个Rect对象rect(100, 50, 50, 100),那么rect会有以下几个功能: rect.area(); //返回rect的面积 5000 rect.size(); //返回 ...

  6. MyBatis数据库连接的基本使用-补充Mapper映射器

    补充 Mapper映射器的使用: Mapper映射器,google添加.Mapper映射器是将mapper.xml中配置的sql id,parameterType和resultMap按照规则一一映射到 ...

  7. package.json bin

    [package.json bin] 1.bin field in your package.json which is a map of command name to local file nam ...

  8. The CHAR and VARCHAR Types

    [The CHAR and VARCHAR Types] The CHAR and VARCHAR types are declared with a length that indicates th ...

  9. 求值器本质--eval&apply

    最近跟着(How to Write a (Lisp) Interpreter (in Python))使用python实现了一个简易的scheme解释器.不得不说使用python这类动态语言实现不要太 ...

  10. 【Django】关于ORM的使用

    添加模型并映射到数据库中: 1. 在 settings.py 中,配置好 DATABASES ,做好数据库相关的配置. 以mysql为例: DATABASES = { 'default': { 'EN ...