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 ...
随机推荐
- MySQL pt-table-checksum及pt-table-sync校验及修复主从一致性
[pt-table-checksum]pt-table-checksum是percona-toolkit系列工具中的一个, 可以用来检测主. 从数据库中数据的一致性.其原理是在主库上运行, 对同步的表 ...
- RabbitMQ(1) 核心概念
消息中间价 消息中间价,也称消息队列,是分布式式系统中常用的中间价. 通过消息中间价传递消息,使得各个子系统解耦,异步通信. 目前业界有许多消息队列的实现,如RabbitMQ.Kafka.Active ...
- jQuery动画与特效
参考:jQuery权威指南jQuery初步jQuery选择器jQuery操作domjQuery操作dom事件jQuery插件jQuery操作AjaxjQuery动画与特效jQuery实现导航栏jQue ...
- Week12《java程序设计》第12次作业总结
Week12<java程序设计>第12次作业总结 1. 本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结多流与文件相关内容. 2. 面向系统综合设计-图书馆管理系统或购物车 ...
- 201621123006 《Java程序设计》第2周学习总结
1. 本周学习总结 以几个关键词描述本周的学习内容.并将关键词之间的联系描述或绘制出来. 原则:少而精,自己写.即使不超过5行也可,但请一定不要简单的复制粘贴. java数据类型:java数据类型分为 ...
- APUE学习笔记——6 系统数据文件与信息
1.用户口令:/etc/passwd文件 该文件中包含下列结构体信息.其中,当下主修熊passwd不再这里显示,是使用了一个占位符. struct passwd { char * pw_name; / ...
- L164
“TAKE ONLY memories, leave only footprints” is more than a hiking motto at the Sagarmatha National P ...
- c# DataTable 导出csv文件
using System; using System.Data; using System.Configuration; using System.Collections.Generic; using ...
- Android支持Split Apks后,如何获得指定包名下的所有类
从Android5.0以后,支持多个apk动态部署,这导致以前通过单一apk获取包路径下的所有类的方法失效,不过稍微修改一下原先的代码就可以,代码如下 public static final List ...
- Java基础拾遗(二)
(尊重劳动成果,转载请注明出处:http://blog.csdn.net/qq_25827845/article/details/76358523冷血之心的博客) 马上就要秋招了,新的一轮笔试面试马上 ...