1005. Spell It Right (20)

时间限制
400 ms
内存限制
65536 kB
代码长度限制
16000 B
判题程序
Standard
作者
CHEN, Yue

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 (<= 10100).

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 <cstdio>
#include <cstring>
#include <string>
#include <queue>
#include <stack>
#include <iostream>
using namespace std;
string digits[]={"zero","one","two","three","four","five","six","seven","eight","nine"};
int main(){
string ss;
int sum=,i=,csum=;
cin>>ss;
while(i<ss.length()){
sum+=ss[i++]-'';
}
if(!sum){
cout<<digits[sum]<<endl;
return ;
}
stack<string> s;
while(sum){
s.push(digits[sum%]);
sum/=;
}
cout<<s.top();
s.pop();
while(!s.empty()){
cout<<" "<<s.top();
s.pop();
}
return ;
}

pat1005. Spell It Right (20)的更多相关文章

  1. PAT---1005. Spell It Right (20)

    #include<iostream> #include<stack> #include<string.h> ]= {"zero", " ...

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

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

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

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

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

  7. 1005 Spell It Right (20)(20 point(s))

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

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

  9. PAT (Advanced Level) 1005. Spell It Right (20)

    简单题. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> ...

随机推荐

  1. javascript点击变绿色再点击变红色

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  2. spring boot项目分享

    Spring boot项目分享 以下项目是我自己做的一些练习项目,有兴趣的小伙伴可以下载下来看下 1.员工管理系统 下载地址:我的github 后续会继续补充

  3. 简单的opengl步骤模板

    以下内容整理自:https://learnopengl-cn.github.io/01%20Getting%20started/03%20Hello%20Window/ 一.初始化 glfw 并设置相 ...

  4. [agc008f] Black Radius 树形dp

    Description ​ 给你一棵有NN个节点的树,节点编号为11到NN,所有边的长度都为11 ​ "全"对某些节点情有独钟,这些他喜欢的节点的信息会以一个长度为NN的字符串ss ...

  5. 【bzoj1000】A+B Problem

    Description 输入两个数字,输出它们之和 Input 一行两个数字A,B(0<=A,B<100) Output 输出这两个数字之和 Sample Input 1 2 Sample ...

  6. [SDOi2012]Longge的问题 BZOJ2705 数学

    题目背景 SDOi2012 题目描述 Longge的数学成绩非常好,并且他非常乐于挑战高难度的数学问题.现在问题来了:给定一个整数N,你需要求出∑gcd(i, N)(1<=i <=N). ...

  7. [JSOI2007]麻将 模拟 BZOJ1028

    题目描述 麻将是中国传统的娱乐工具之一.麻将牌的牌可以分为字牌(共有东.南.西.北.中.发.白七种)和序数牌(分为条子.饼子.万子三种花色,每种花色各有一到九的九种牌),每种牌各四张. 在麻将中,通常 ...

  8. js 任意元素解绑任意事件的兼容代码

    hmtl代码: <input type="button" value="按钮" id="btn"/> <input typ ...

  9. P2050 [NOI2012]美食节(费用流)

    P2050 [NOI2012]美食节 P2053 [SCOI2007]修车的加强版 因为数据较大,一次性把所有边都加完会T 于是我们每次只连需要的边跑费用流 就是开始先连所有厨师做倒数第1道菜 跑费用 ...

  10. python学习,day2:列表的复制

    主要涉及列表的潜复制(第二层受后面修改的影响)和深复制(不受后面修改的影响) 代码如下 # coding=utf-8 # Author: RyAn Bi import copy names = ['A ...