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. 19. --mus-- 音乐,娱乐(词20)

  2. 跳跳虎回家(国庆10.1模拟赛T2)

    题目: [题目描述] 跳跳虎在外面出去玩忘了时间,现在他需要在最短的时间内赶回家. 跳跳虎所在的世界可以抽象成一个含有 n 个点的图(点编号从 1 到 n ),跳跳虎现在在 1 号点,跳跳虎的家在 n ...

  3. mysql 中判断表是否存在 以及表存在则删除

    select * from information_schema.tables where table_name ='student';select * from information_schema ...

  4. PHP里获取一维数组里的最大值和最小值

    <?php $arr = ['10','100','50','90','2','5']; $min = min($arr); $max = max($arr); echo $min.PHP_EO ...

  5. Oracle(字符函数)

    单行函数语法: 语法:funcation_name(列 | 表达式[, 参数1, 参数2]) 单行函数主要分为以下几种: 字符函数:接收数据返回具体的字符信息 数值函数:对数字进行处理,例如:四舍五入 ...

  6. L1-048. 矩阵A乘以B

    水题不多说,直接上代码:#include<stdio.h> using namespace std; int main() { ][]; ][]; int m,n; int x,y; sc ...

  7. webpack优化记录

    什么是Webpack  .  ( 模块打包机,分析项目结构,找到js不能识别的代码语言,转换和打包后,供browser使用 ) WebPack可以看做是模块打包机:它做的事情是,分析你的项目结构,找到 ...

  8. 如何在Vue项目中使用vw实现移动端适配(转)

    有关于移动端的适配布局一直以来都是众说纷纭,对应的解决方案也是有很多种.在<使用Flexible实现手淘H5页面的终端适配>提出了Flexible的布局方案,随着viewport单位越来越 ...

  9. 学习笔记41—ttest误区

    1.grapPad软件里面双T结果和matlab,EXCEl里面双T结果一致时,设置如下:

  10. 在cmd中登录MySQL数据库

    mysql -uroot -p 输入密码,即可