浙大PAT-1002
1002. 写出这个数 (20)
读入一个自然数n,计算其各位数字之和,用汉语拼音写出和的每一位数字。
输入格式:每个测试输入包含1个测试用例,即给出自然数n的值。这里保证n小于10100。
输出格式:在一行内输出n的各位数字之和的每一位,拼音数字间有1 空格,但一行中最后一个拼音数字后没有空格。
输入样例:
1234567890987654321123456789
输出样例:
yi san wu 尼玛,提交告诉我格式错误,原来题目要求最后不加空格。
#include <stdio.h>
#include <string.h>
#include <malloc.h> #define MAX_NUM 100 void print_decimal(char num)
{
switch(num)
{
case '':
printf("ling");
break;
case '':
printf("yi");
break;
case '':
printf("er");
break;
case '':
printf("san");
break;
case '':
printf("si");
break;
case '':
printf("wu");
break;
case '':
printf("liu");
break;
case '':
printf("qi");
break;
case '':
printf("ba");
break;
case '':
printf("jiu");
break;
default:
printf("fault");
break;
}
} int main(int argc,char **argv)
{
char nInput[MAX_NUM];
int nWidth = ;
int i = ;
int sum = ;
char strSum[MAX_NUM]; gets(nInput);
while(nInput[i] != '\0')
{
sum += (nInput[i++] - '');
}
sprintf(strSum,"%d",sum); while(sum>)
{
sum = sum/;
nWidth++;
} for(i=;i<nWidth-;i++)
{
print_decimal(strSum[i]);
printf(" ");
}
print_decimal(strSum[i]);
return ;
}
浙大PAT-1002的更多相关文章
- A题进行时--浙大PAT 1001-1010
pat链接:http://pat.zju.edu.cn 1 #include<stdio.h> 2 int main(){ 3 int a,b; 4 int c; 5 while(scan ...
- 浙大 PAT 乙级 1001-1075 目录索引
1001. 害死人不偿命的(3n+1)猜想 1002. 写出这个数 1003. 我要通过! 1004. 成绩排名 1005. 继续(3n+1)猜想 1006. 换个格式输出整数 1007. 素数对猜想 ...
- PAT 1002
1002. A+B for Polynomials (25) This time, you are supposed to find A+B where A and B are two polynom ...
- 浙大pat 1035题解
1035. Password (20) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue To prepare f ...
- 浙大pat 1025题解
1025. PAT Ranking (25) 时间限制 200 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Programmi ...
- PAT 1002. A+B for Polynomials (25) 简单模拟
1002. A+B for Polynomials (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue T ...
- PAT 1002 写出这个数 (20)(代码)
1002 写出这个数 (20)(20 分) 读入一个自然数n,计算其各位数字之和,用汉语拼音写出和的每一位数字. 输入格式:每个测试输入包含1个测试用例,即给出自然数n的值.这里保证n小于10^100 ...
- pat 1002 A+B for Polynomials (25 分)
1002 A+B for Polynomials (25 分) This time, you are supposed to find A+B where A and B are two polyno ...
- PAT 1002. 写出这个数 (20)
读入一个自然数n,计算其各位数字之和,用汉语拼音写出和的每一位数字. 输入格式:每个测试输入包含1个测试用例,即给出自然数n的值.这里保证n小于10100. 输出格式:在一行内输出n的各位数字之和的每 ...
- A题进行时--浙大PAT 1021-1030
1021: #include<stdio.h> #include<string.h> #include<vector> #include<queue> ...
随机推荐
- 【BZOJ-1068】压缩 区间DP
1068: [SCOI2007]压缩 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 1001 Solved: 615[Submit][Status][ ...
- 【BZOJ-1911】特别行动队 DP + 斜率优化
1911: [Apio2010]特别行动队 Time Limit: 4 Sec Memory Limit: 64 MBSubmit: 3478 Solved: 1586[Submit][Statu ...
- ES5/ES6的区别研究(ECMAScript)
我所理解的概念应该是语法的区别和特性的区别 这里是ECMAScript的解析http://baike.baidu.com/item/ECMAScript 参考: (ES6)http://es6.rua ...
- oracle11g dataguard 安装手册(转)
文章转自:http://www.cnblogs.com/tippoint/archive/2013/04/18/3029019.html 一.前言: 网络上关于dataguard的配置文章很多,但 ...
- bzoj1124[POI2008]枪战maf
这代码快写死我了.....死人最多随便推推结论.死人最少,每个环可以单独考虑,每个环上挂着的每棵树也可以分别考虑.tarjan找出所有环,对环上每个点,求出选它和不选它时以它为根的树的最大独立集(就是 ...
- 手机卫士开发记录之handler错误
- CentOS下X Window与命令行界面的切换
[Ctrl] + [Alt] + F1~F6:文字界面登陆tt1~tty6 [Ctrl] + [Alt] + F7:图形界面桌面 从文字界面启动图形界面的命令:startx
- 加州大学伯克利分校Stat2.2x Probability 概率初步学习笔记: Section 1 The Two Fundamental Rules (1.5-1.6)
Stat2.2x Probability(概率)课程由加州大学伯克利分校(University of California, Berkeley)于2014年在edX平台讲授. PDF笔记下载(Acad ...
- CF 701B Cells Not Under Attack(想法题)
题目链接: 传送门 Cells Not Under Attack time limit per test:2 second memory limit per test:256 megabyte ...
- Nginx反向代理tomcat
location /gm { root html; proxy_pass http://localhost:8080/gm; proxy_set_hea ...