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 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 (≤).

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<bits/stdc++.h>
using namespace std;
typedef long long ll; vector<string> vec={{"zero"},{"one"},{"two"},{"three"},{"four"},{"five"},{"six"},{"seven"},{"eight"},{"nine"}}; vector<int> temp; int main(){
string s;
cin >> s;
ll sum = ;
for(int i=;i < s.size();i++){
sum += (s[i]-'');
}
if(sum == ) cout << vec[];
while(sum){
temp.push_back(sum%);
sum = sum/;
}
for(int i=temp.size()-;i>=;i--){
cout << vec[temp[i]];
if(i) cout << " ";
} return ;
}

sum = 0的情况要注意,不会进入循环。

PAT 1005 Spell It Right的更多相关文章

  1. PAT 1005 Spell It Right 字符串处理

    Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output e ...

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

  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 (20)(代码)

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

  5. PAT甲1005 Spell it right【字符串】

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

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

  7. PAT 1005

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

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

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

随机推荐

  1. JavaScript中的方法事件和函数的方法的三种方法

    js中的很多事件  而事件相对应的就是方法(函数 )那么今天所说的就是这三种方法      已onclick事件为例 1: 基本方法 <div id="a" onclick= ...

  2. Addition Chains

    题目描述: 一个与 n 有关的整数加成序列 < a0 , a1 , a2 ...am> 满足一下四个条件: 1.a0=1 2.am=n 3.a0<a1<a2<...< ...

  3. WebStorm破解方法

    http://www.jianshu.com/p/85266fa16639 http://idea.lanyus.com/ webstorm 入门指南 破解方法 1. 下载的WebStorm http ...

  4. java.lang.TypeNotPresentException: Type javax.xml.bind.JAXBContext not present错误

    今天在搭建spring cloud的时候,发现一直报“java.lang.TypeNotPresentException: Type javax.xml.bind.JAXBContext not pr ...

  5. CentOS7 安装Perl

    官网:http://www.cpan.org/src/ wget https:.tar.gz cd perl- ./Configure -des -Dprefix=$HOME/localperl ma ...

  6. Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.3:compile

    完整的错误信息: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.3:compile ( ...

  7. [转]pugixml使用教程

    转自:https://www.cnblogs.com/ltm5180/p/3989125.html pugixml介绍 pugixml是一个高性能.轻量级并且简单易用的xml解析库,支持UTF8 en ...

  8. [转]C和C++运行时库

    转自csdn原文:https://blog.csdn.net/ithzhang/article/details/20160009 图片请去原文查看 在使用VC构建项目时,经常会遇到下面的链接错误: 初 ...

  9. WSL(Windows Subsystem for Linux) 适用于Linux的Windows子系统

    打开 Microsoft Store , 搜索 Linux .选择 Ubuntu , 仔细看介绍,尤其是安装前的说明 ========================================= ...

  10. Grunt、Gulp区别 webpack、 requirejs区别

    1. 书写方式 grunt 运用配置的思想来写打包脚本,一切皆配置,所以会出现比较多的配置项,诸如option,src,dest等等.而且不同的插件可能会有自己扩展字段,导致认知成本的提高,运用的时候 ...