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. SQLServer 统计查询语句消耗时间

    --方法1[set statistic ]: set statistics time on go --执行语句 xxxx go set statistics time off --方法2[getDat ...

  2. 「POJ 1741」Tree

    题面: Tree Give a tree with n vertices,each edge has a length(positive integer less than 1001). Define ...

  3. 个人JS体系整理(三)

    一. 严格模式 JavaScript 严格模式(strict mode)即在严格的条件下运行.首先声明,严格模式是ES5中提出来的,准确来说就是一句指令Use strict,它的目的是指定代码在严格条 ...

  4. stream.fail() eof() EOF

    ifstream infile("student.dat"); while((c=infile.get())!=EOF){}    //EOF的值是-1 但在 #include&l ...

  5. curl下载目录

    http://ftp.loongnix.org/os/loongnix/1.0/SRPMS/ wget wget -c -r -np -k -L -p

  6. 处理json

    一.json json是一个字符串,只不过长得比较像字典.使用json函数需要导入json库,即import json json的格式只有双引号,不可用单引号 1.json.loads()和json. ...

  7. PLSQL导出语句的查询结果

    不需要把全部结果都展示出来

  8. 在请求中存取属性setAttribute&getAttribute方法

    在请求中保存属性: public void setAttribute(String name,Object o) request.setAttribute("mess"," ...

  9. 18、OpenCV Python 简单实现一个图片生成(类似抖音生成字母人像)

    __author__ = "WSX" import cv2 as cv import numpy as np def local_threshold(img): #局部阈值 gra ...

  10. sqoop常用语句

    1,列出全部数据库 sqoop list-databases  --connect jdbc:sqlserver://10.10.10.2 --username sa --password 1 2,导 ...