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. Microsoft® SQL Server® 2012 功能包

    Microsoft® SQL Server® 2012 功能包 http://www.microsoft.com/zh-cn/download/details.aspx?id=29065 Micros ...

  2. 吴裕雄 python神经网络(8)

    # -*- coding=utf-8 -*-import numpy as npimport kerasfrom keras.models import Sequentialfrom keras.la ...

  3. tensorflow 指定使用gpu处理,tensorflow占用多个GPU但只有一个在跑

    我们在刚使用tensorflow的过程中,会遇到这个问题,通常我们有多个gpu,但是 在通过nvidia-smi查看的时候,一般多个gpu的资源都被占满,但是只有一个gpu的GPU-Util 和 21 ...

  4. Conscription-最小生成树-Kruskal

    Windy has a country, and he wants to build an army to protect his country. He has picked up N girls ...

  5. canvas画布内部重复画圆

    <!DOCTYPE html><html><head> <title>canvas example</title> <meta cha ...

  6. jquery 页面传值 汉字

    function getURLParameter(name) { return decodeURIComponent( (new RegExp('[?|&]' + name + '=' + ' ...

  7. JMeter学习(三)元件的作用域与执行顺序(转载)

    转载自 http://www.cnblogs.com/yangxia-test 1.元件的作用域 JMeter中共有8类可被执行的元件(测试计划与线程组不属于元件),这些元件中,取样器是典型的不与其它 ...

  8. python--第一天总结

    [变量]1.变量定义的规则: 变量名只能是 字母.数字或下划线的任意组合    变量名的第一个字符不能是数字    以下关键字不能声明为变量名    ['and', 'as', 'assert', ' ...

  9. Idea单元测试Junit Generator设置

    0. setting--->plugins--->brose repostories-->输入JUnitGenerator V2.0 1.junit generator自动生成测试代 ...

  10. DHCP server 冒充及DOS攻击处理方案

    一.DHCP服务器在运维上存在的常见问题: 1. DHCP服务器冒充 在DHCP服务器和客户端之间没有认证机制,如果在DHCP server覆盖的网络上随意接入一个DHCP server,就有可能造成 ...