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

很简单的题,最开始错了两次,N最大是10得100次方,用整形存储肯定不够,用字符串存储后就过了

#include <iostream>
#include <string>
#include <map> using namespace std; map<char,string> m;
int result[]; int main()
{
m[]="zero";
m[]="one";
m[]="two";
m[]="three";
m[]="four";
m[]="five";
m[]="six";
m[]="seven";
m[]="eight";
m[]="nine";
string n;
long int sum=;
cin>>n;
int b,i=;
while(n[i]!='\0'){
b=n[i]-;
sum=sum+b;
i++;
}
int x,countnum=;
while(sum){
x=sum%;
result[countnum]=x;
countnum++;
sum=sum/;
}
cout<<m[result[countnum-]];
for(int i=countnum-;i>=;i--){
cout<<" "<<m[result[i]];
} return ;
}

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

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

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

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

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

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

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

  7. PAT 甲级 1005. Spell It Right (20) 【字符串】

    题目链接 https://www.patest.cn/contests/pat-a-practise/1005 思路 因为 n <= 10^100 所以 要用字符串读入 但是 100 * 100 ...

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

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

  9. PAT甲题题解-1005. Spell It Right (20)-数位求和,水

    把每个位上的数字求和sum,然后以英文单词的形式输出sum的每个位 #include <iostream> #include <cstdio> #include <alg ...

随机推荐

  1. (转)HTTP 长连接和短连接

    1. HTTP协议与TCP/IP协议的关系 HTTP的长连接和短连接本质上是TCP长连接和短连接.HTTP属于应用层协议,在传输层使用TCP协议,在网络层使用IP协议.IP协议主要解决网络路由和寻址问 ...

  2. Leetcode: Heaters

    Winter is coming! Your first job during the contest is to design a standard heater with fixed warm r ...

  3. windows shell api SHEmptyRecycleBin 清空回收站

    HRESULT SHEmptyRecycleBin( HWND hwnd, LPCTSTR pszRootPath, DWORD dwFlags ); hwnd 父窗口句柄 pszRootPath 将 ...

  4. SQL语句大全(转载)

    经典SQL语句大全 一.基础 1.说明:创建数据库CREATE DATABASE database-name 2.说明:删除数据库drop database dbname3.说明:备份sql serv ...

  5. Apache部署django项目

    在此之前,我们一直使用django的manage.py 的runserver 命令来运行django应用,但这只是我们的开发环境,当项目真正部署上线的时候这做就不可行了,必须将我们的项目部署到特定的w ...

  6. js中子父页面数据传递与方法调用

    A父页面 ,B为子页面 1.父页面调用子页面 A中调用B中方法:self.frames[iframeName].BFunction(); 注:iframeName:为父页面中iframe的name属性 ...

  7. app加固

    为什么要加固APP? 答:因为黑客通过反编译APK得到源码后,会在应用中插入代码,获取利益,比如添加广告,盗取用户账号.密码,后台定制活动等.   反编译的方法? 反编译是指apk文件通过反编译工具( ...

  8. 在Mac中保护私密文件,隐藏文件

    在个人电脑中我们有些私密文件或者资料是不希望被人发现或者使用.保护私密文件的方式有很多,比如对文件进行加密,隐藏文件,修改文件后缀等.在Mac中我们也可以通过一些简单方式保护私密文件.这里我们简单介绍 ...

  9. js获取元素样式

    http://blog.sina.com.cn/s/blog_89cd68470101i108.html

  10. 【已解决】新搭建的VPN服务器客户端无法正常连接

    昨天花了一天的时间,终于把VPN服务器搭建好了.但是客户端却一直提示无法拨号成功.查看VPN日志如下:[root@localhost log]# tail -f messages Jun 13 14: ...