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 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 (<= 10^100^).
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<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<map>
#include<vector>
#include<stack>
#define inf 0x3f3f3f3f
using namespace std;
int main()
{
char a[];
while(cin>>a)
{
int s=;
int l=strlen(a);
for(int i=;i<l;i++)
{
s+=(int)(a[i]-'');
}
stack<int>q;
while(s>=)
{
int a=s%;
q.push(a);
s/=;
}
q.push(s);
int k=;
while(!q.empty())
{
if(k!=)
cout<<" ";
k++;
int i=q.top();
q.pop();
if(i== )
cout<<"zero";
if(i==)
cout<<"one";
if (i==)
cout<<"two";
if (i==)
cout<<"three";
if (i==)
cout<<"four";
if (i==)
cout<<"five";
if (i==)
cout<<"six";
if (i==)
cout<<"seven";
if (i==)
cout<<"eight";
if (i==)
cout<<"nine";
}
cout<<endl;
}
return ;
}
PTA 1005 Spell It Right (20)(20 分)水题的更多相关文章
- 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 ...
- 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 ...
- 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 the ...
- 1005. Spell It Right(20)—PAT 甲级
Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output e ...
- PTA 1005 Spell It Right
题目描述: Given a non-negative integer N, your task is to compute the sum of all the digits of N, and ou ...
- PTA | 1005 继续(3n+1)猜想 (25分)
卡拉兹(Callatz)猜想已经在1001中给出了描述.在这个题目里,情况稍微有些复杂. 当我们验证卡拉兹猜想的时候,为了避免重复计算,可以记录下递推过程中遇到的每一个数.例如对 n=3 进行验证的时 ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- 淘宝TDDL深入浅出
前言 在开始讲解淘宝的 TDDL(Taobao Distribute Data Layer) 技术之前,请允许笔者先吐槽一番.首先要开喷的是淘宝的社区支持做的无比的烂, TaoCode 开源社区上面, ...
- Runtime获取类的属性列表和方法列表
Runtime获取类的属性列表和方法列表 Runtime很强大,他使得OC中没有真正意义上的私有属性和私有方法,我们可以利用OC的运行时拿到一个类的任何方法和任何属性,然后动态的去调用方法,objc_ ...
- 词频统计 ——Java
github地址 :https://github.com/NSDie/personal-project 一.计划表 PSP2.1 Personal Software Process Stages 预估 ...
- Django-RestfulFramework --- DRF
>> (1)RESTful api 规范 和 DRF 的基本介绍 >> (2)DRF 的 认证系统实现 >> (3)DRF 的 权限系统实现 >> (4 ...
- python的if判断补充
python的if判断补充 exit_flag = False # 标识符 if exit_flag == False: print('exit_flag == False') exit_flag = ...
- ubuntu版的sublime-text3输入中文问题
前言 sublime-text3中看又中用,但是呢,ubuntu下有个问题,就是无法输入中文.这很难受啊,要写一些重要的内容时,总还是中文来的顺畅. 解决办法 工具:sublime-text-imfi ...
- 隐居网V2.0
经过一个月加班加点的努力,我们终于把隐居网V2.0版做好了(一个设计两个前端三个程序).上一版的隐居网因为经验不够底层架构没搭好(前台和后台都是),又是赶工期,导致后面越做越坑爹.所谓从哪里跌倒从哪里 ...
- HDU - 5306 Gorgeous Sequence (吉司机线段树)
题目链接 吉司机线段树裸题... #include<bits/stdc++.h> using namespace std; typedef long long ll; ,inf=0x3f3 ...
- 考研系列 HDU2242之空调教室 tarjan
众所周知,HDU的考研教室是没有空调的,于是就苦了不少不去图书馆的考研仔们.Lele也是其中一个.而某教室旁边又摆着两个未装上的空调,更是引起人们无限YY. 一个炎热的下午,Lele照例在教室睡觉的时 ...
- stm32寄存器版学习笔记08 DMA
DMA(Direct Memory Access),直接存储器访问.DMA传输方式无需CPU直接控制传输,通过硬件为RAM与I/O设备开辟一条直接传送数据的通路,使CPU效率大大提高.stm32f10 ...