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. Vue.extend提供自定义组件的构造器

    Vue.extend 返回的是一个“扩展实例构造器”,也就是预设了部分选项的Vue实例构造器.经常服务于Vue.component用来生成组件,可以简单理解为当在模板中遇到该组件名称作为标签的自定义元 ...

  2. IAR中的 identifier "FILE" is undefined 问题

     最近由于希望使用IAR的printf()函数方便进行打印字符,出现IAR报错,即:identifier "FILE" is undefined,问题得以解决.   (1)进行pr ...

  3. 剥开比原看代码13:比原是如何通过/list-balances显示帐户余额的?

    作者:freewind 比原项目仓库: Github地址:https://github.com/Bytom/bytom Gitee地址:https://gitee.com/BytomBlockchai ...

  4. js 字符串加密解密

    Welcome to jzzy.com

  5. Jquery 点击事件重复获取叠加 (一)

    用jquery添加绑定事件 添加多少次 点击的时候就触发多少次 如果想解决这个问题 就在点击函数里先用 $(对象).off("click") 取消上一次的点击事件 上码: $(&q ...

  6. Javascript 垃圾回收机制

    转载于https://www.cnblogs.com/zhwl/p/4664604.html 一.垃圾回收的必要性 由于字符串.对象和数组没有固定大小,所有当他们的大小已知时,才能对他们进行动态的存储 ...

  7. Codeforces 786 A. Berzerk

    题目链接:http://codeforces.com/problemset/problem/786/A 这个题出做$DIV2$的$C$以及$DIV1$的A会不会难了一点啊... 做法和题解并不一样,只 ...

  8. C# 整理DotNetBar中SuperGridControl的一些基础属性

    //控制表格只能选中单行 superGridControl1.PrimaryGrid.MultiSelect = false; superGridControl1.PrimaryGrid.Initia ...

  9. selenium打开chrome时,出现 "您使用的是不受支持的命令行标记:--ignore-certificate-errors""

    from selenium import webdriveroptions = webdriver.ChromeOptions()options.add_experimental_option(&qu ...

  10. 常见的Java面试题及答案整理

    1. 基础篇 1. 面向对象特征:封装,继承,多态和抽象 封装封装给对象提供了隐藏内部特性和行为的能力.对象提供一些能被其他对象访问的方法来改变它内部的数据.在 Java 当中,有 3 种修饰符: p ...