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. 【ASP.NET】System.Web.Routing - HttpMethodConstraint Class

    你可以自己定义你的ASP.NET程序接收的get post put 或者delete请求. 使用这个约束的方式为: void Application_Start(object sender, Even ...

  2. 【NOIP 2015】Day2 T3 运输计划

    Problem Background 公元 \(2044\) 年,人类进入了宇宙纪元. Description 公元\(2044\) 年,人类进入了宇宙纪元. $L $国有 \(n\) 个星球,还有 ...

  3. Python: 字典应用题

    Write a program to read through the mbox-short.txt and figure out who has sent the greatest number o ...

  4. 2019年前端面试题 | CSS篇 (更新于4月15日)

    虽说刷面试题有走捷径之嫌,但我发现,对于我这样没有工作经历的人来说,其实是拓展自己实战技能和加深知识理解的一个好机会. 分享出来,也希望大家不要背完了事,正经的去细细琢磨各种原由. 本篇是一个题目合集 ...

  5. 真刀实战地搭建React+Webpack+Express搭建一个简易聊天室

    一.前面bb两句 因为自惭(自残)webpack配置还不够熟悉,想折腾着做一个小实例熟悉.想着七夕快到了,做一个聊天室自己和自己聊天吧哈哈.好了,可以停止bb了,说一下干货. 二. 这个项目能学到啥? ...

  6. 2017"百度之星"程序设计大赛 - 复赛 01,03,05

    Arithmetic of Bomb Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Other ...

  7. spring boot Tomcat访问日志

    1.Tomcat设置访问日志 <Host name="localhost" appBase="webapps" unpackWARs="true ...

  8. leetcode 29-> Divide Two Integers without using multiplication, division and mod operator

    class Solution(object): def divide(self, dividend, divisor): """ :type dividend: int ...

  9. 使用pymongo连接mongodb时报错:pymongo.errors.OperationFailure: not authorized

    连接本机或局域网部署的mongodb时可以用以下方法: from urllib import parse from pymongo import MongoClient host = '*.*.*.* ...

  10. Ado.net之存储过程的使用【三】

    重点是红色标记区域的代码,设置本次执行的是存储过程,如果不设置,默认操作的是sql语句 private void LoadData() { string constr = @"databas ...