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. vue 巧妙的运用sass px 转 rem

    <template> <div id="app"> <!-- <img src="./assets/logo.png"> ...

  2. 使用yii\filters下的比如\PageCache需要在web.php里面的组件上配置'cache' => [ 'class' => 'yii\caching\FileCache', ],

    public function behaviors(){ /*需要在config文件下的web.php里面加上 'cache' => [ 'class' => 'yii\caching\F ...

  3. java-学习1

    作为一个想要深入的程序猿,只是学习前端是不够的,我总结我的前端工作是围绕着html.css.js展开写的再好也是展现在表面,所以 我想学习一门能够深入的后台语言,想来想去我还是选择java作为以后深入 ...

  4. RepeatMasker

    1.简介 RepeatMasker是一款基于Library-based,通过相似性比对来识别重复序列,可以屏蔽序列中转座子重复序列和低复杂度序列(默认将其替换成N).提供有在线服务.RepeatMas ...

  5. asp.net mvc areas

    http://www.codeproject.com/Articles/714356/Areas-in-ASP-NET-MVC

  6. python-ceilometerclient命令行(2)

    命令行解析工具argparse argparse是python标准库中的模块,利用argparse,可以完成对命令行的参数定义.解析以及后续的处理.一个简单的例子: # coding:utf-8 im ...

  7. JMeter3.0(三十八)图形化HTML报告中文乱码问题处理(转载)

    转载自 http://www.cnblogs.com/yangxia-test 由于个人在JMeter 3.0的实际应用中,脚本中的Test Plan/Sampler等元件命名都没有使用中文,所以在之 ...

  8. tomcat部署war包

    部署步骤 1.下载tomcat 直接在网上下载即可,随便把包下到一个地方 下面文中的xxx均代表tomcat的安装目录   2.将java工程导出war包 在intellij idea的执行左侧选中t ...

  9. shell 通过shift获得某位后的入参

    有时shell的入参个数不定,想要获得第2位后的参数,作为新的入参调用其他脚本   通常这时候想到的方法是用遍历,例如下面的方法: for (( i=2;i<=$#;i++)) do       ...

  10. pep8 && pep20

    pep8(部分,遇到问题再补充) 1.不建议使用tab键来空格,避免不必要的空格.操作符左右各加一个空格,函数默认参数使用的赋值符左右省略空格. 2.类和top-level函数定义之间空两行:类中的方 ...