PAT 07-0. 写出这个数
来源:互联网 发布:壁虎java基础视频下载 编辑:程序博客网 时间:2024/05/20 04:26
读入一个自然数n,计算其各位数字之和,用汉语拼音写出和的每一位数字。
输入格式:每个测试输入包含1个测试用例,即给出自然数n的值。这里保证n小于10100。
输出格式:在一行内输出n的各位数字之和的每一位,拼音数字间有1 空格,但一行中最后一个拼音数字后没有空格。
输入样例:
1234567890987654321123456789
输出样例:
yi san wu
/*c07-0*/#include <stdio.h> void nianshuzi(long in){ char *ch[10]={"ling","yi","er","san","si","wu","liu","qi","ba","jiu"}; char *sh[30]; int flag=0; int i=0; if(in==0){ printf("ling"); return; } if(in<0){ in=-in; flag =1; } if(flag) printf("fu "); while (in){ sh[i] = ch[in%10]; i++; in=in/10; } i-=1; while (i>=0){ if(i) printf("%s ",sh[i]); else printf("%s",sh[i]); i--; } } int main(){ char a; int sum =0; scanf("%c",&a); while(a!='\n'){ sum += a -'0'; scanf("%c",&a); } nianshuzi(sum);}
0 0
- PAT 07-0. 写出这个数
- PAT-写出这个数
- PAT.写出这个数
- PAT:7-0. 写出这个数 (20)
- PAT 1002. 写出这个数
- pat 1002 写出这个数
- PAT 1002 写出这个数
- 1002 写出这个数 PAT
- PAT,1002,写出这个数
- PAT 1002. 写出这个数
- PAT 1002 写出这个数
- PAT-1002. 写出这个数
- PAT乙级-写出这个数
- PAT 1002. 写出这个数
- PAT 1002写出这个数
- PAT 1002 写出这个数
- Pat 1002. 写出这个数
- pat 1002 写出这个数
- 最大连续子序列的和
- 纪念性的一天——博客开通第一天
- 5.非关系型数据库(Nosql)之mongodb:创建集合,备份与导入导出, 数据还原,导入导出
- 04-4. 猜数字游戏(15)
- JavaScript 获取页面宽度高度大全
- PAT 07-0. 写出这个数
- SET DEADLOCK_PRIORITY (Transact-SQL)
- SQL Server 数据库定时自动备份
- Linux x64 Hadoop-2.4.1配置-解决错误Unable to load native-hadoop library for your platform
- Arcgis for Javascript实现两个地图的联动
- 创建处理文档索的引类:IndexProcessor
- 08-1. 求一批整数中出现最多的个位数字(20)
- 【寄存器】
- The reference to entity "characterEncoding" must end with the ';' delimiter