PAT (Advanced Level) 1005. Spell It Right (20)
简单题。
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<vector>
using namespace std; const int maxn=+;
char s[maxn];
int tmp[maxn],tot;
char ans[][]={
"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"
}; int main()
{
scanf("%s",s);
int num=; for(int i=;s[i];i++) num=num+s[i]-'';
if(num==)
{
printf("zero\n");
}
else{
tot=; while(num) tmp[tot++]=num%,num=num/;
for(int i=tot-;i>=;i--)
{
printf("%s",ans[tmp[i]]);
if(i>) printf(" ");
else printf("\n");
}
}
return ;
}
PAT (Advanced Level) 1005. Spell It Right (20)的更多相关文章
- PAT (Advanced Level) Practice 1046 Shortest Distance (20 分) 凌宸1642
PAT (Advanced Level) Practice 1046 Shortest Distance (20 分) 凌宸1642 题目描述: The task is really simple: ...
- PAT (Advanced Level) Practice 1042 Shuffling Machine (20 分) 凌宸1642
PAT (Advanced Level) Practice 1042 Shuffling Machine (20 分) 凌宸1642 题目描述: Shuffling is a procedure us ...
- PAT (Advanced Level) Practice 1041 Be Unique (20 分) 凌宸1642
PAT (Advanced Level) Practice 1041 Be Unique (20 分) 凌宸1642 题目描述: Being unique is so important to peo ...
- PAT (Advanced Level) Practice 1015 Reversible Primes (20 分) 凌宸1642
PAT (Advanced Level) Practice 1015 Reversible Primes (20 分) 凌宸1642 题目描述: A reversible prime in any n ...
- PTA (Advanced Level) 1005 Spell It Right
Spell It Right Given a non-negative integer N, your task is to compute the sum of all the digits of ...
- PAT (Advanced Level) Practice 1152 Google Recruitment (20 分)
In July 2004, Google posted on a giant billboard along Highway 101 in Silicon Valley (shown in the p ...
- PAT (Advanced Level) 1054. The Dominant Color (20)
简单题 #include<cstdio> #include<cstring> #include<cmath> #include<vector> #inc ...
- PAT (Advanced Level) 1027. Colors in Mars (20)
简单题. #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> ...
- PAT (Advanced Level) 1019. General Palindromic Number (20)
简单题. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> ...
随机推荐
- TOMCAT 优化设置
增加JVM堆内存大小修复JRE内存泄漏线程池设置压缩数据库性能调优Tomcat本地库 第1步 – 提高JVM栈内存Increase JVM heap memory 你使用过tomcat的话,简单的说就 ...
- Android BuildConfig.DEBUG的妙用
在Android开发中,我们使用android.util.Log来打印日志,方便我们的开发调试.但是这些代码不想在发布后执行,我们并不想在软件发布后调试日志被其他开发者看到,现在我的方法是设置一个全局 ...
- adodb.stream对象的方法/属性
Cancel 方法 使用方法如下 Object.Cancel 说明:取消执行挂起的异步 Execute 或 Open 方法的调用.Close 方法 使用方法 ...
- php redis 消息队列
redis是什么东西就不多说了,网上文章一搜一大堆. 首先来说一下我要实现的功能: 类似一个消息中转站吧,如果有人要发送消息,先将消息发到我这里来,然后我这边进行转发,为的就是有一个统一的管理和修改时 ...
- Integer比较值的时候小心使用
package integerdemo; public class IntegerDemo { public static void main(String[] args) { //-128--127 ...
- CodeForces 689C Mike and Chocolate Thieves (二分最大化最小值)
题目并不难,就是比赛的时候没敢去二分,也算是一个告诫,应该敢于思考…… #include<stdio.h> #include<iostream> using namespace ...
- poj 2594 Treasure Exploration(最小路径覆盖,可重点)
题意:选出最小路径覆盖图中所有点,路径可以交叉,也就是允许路径有重复的点. 分析:这个题的难点在于如何解决有重复点的问题-方法就是使用Floyd求闭包,就是把间接相连的点直接连上边,然后就是求最小路径 ...
- 二分图最大匹配 Hopcroft-Karp算法模板
#include <iostream> #include <cstdlib> #include <cstdio> #include <cstring> ...
- 随机法解决TSP问题
TSP问题一直是个头疼的问题,但是解决的方法数不胜数,很多的算法也都能解决.百度资料一大堆,但是我找到了代码比较简练的一种.随机法.下面只是个人的看法而已,如果有任何问题虚心接受. 顾名思义,随机法就 ...
- git rebase 使用
git rebase 不会取回代码 要用git fetch先取回, git rebase 是合并代码. (1)首先用git fetch返回服务器上的代码 (2)首先用git rebase origin ...