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> ...
随机推荐
- fdisk添加磁盘
1. 通过Fdisk查看系统分区详细信息: Fdisk –l 详解: [root@jetsenLin ~]# fdisk -l Disk /dev/sda: 10.7 GB, ...
- Django urls常用匹配语法
url from django.conf.urls import url from . import views urlpatterns = [ url(r'^articles/2003/$', vi ...
- TextUtils判断
System.out.println(TextUtils.isEmpty(null)); System.out.println(TextUtils.isEmpty(""));
- 使用内链接(A a inner join B b on a.xx = b.xx)查询2个表中某一列的相同的字段。
这里一句代码就是查询2个表中某一列的相同,可是查询出来之后B表因为有很多重复的id数据,然而查询出来的数据需要插入到临时表中,临时表的oid是不允许有重复的, 因此需要用到 distinct 函数来取 ...
- 【0-1 背包模板】 poj 3624
先看个未经优化的二维空间dp: #include <iostream> #include <cstdio> #include <cmath> #include &l ...
- cout、cerr、clog
其实大家平常常会用的主要有三个:cout.cerr.clog,首先简单介绍下三者. 这三者在C++中都是标准IO库中提供的输出工具(至于有关的重载问题在此不讨论): cout:写到标准输出的ostre ...
- 构建一个最简单的web应用并部署及启动
第一种构建方式:不使用maven File-new-Dynamic Web Project,用这种方式构建的web项目是在web.xml文件中配置了welcome-file的,但是却没有对应的文件,所 ...
- U盘安装Centos后拔除U盘无法启动问题解决方法
今天安装CentOS后发现把引导文件安装在U盘上了,所以不插U盘就无法进入CentOS系统,在网上找到这种方法成功摆脱U盘启动,避免重新用U盘做引导盘安装系统,简单省事,所以发个帖,留着以后备用. 1 ...
- publish over ssh
http://stackoverflow.com/questions/22158092/jenkins-transferring-0-files-using-publish-over-ssh-plug ...
- hdu 1001 二叉树搜索
Problem Description 判断两序列是否为同一二叉搜索树序列 Input 开始一个数n,(1<=n<=20) 表示有n个需要判断,n= 0 的时候输入结束.接下去一行是一个序 ...