L1-007. 念数字
来源:互联网 发布:电脑软件打开乱码 编辑:程序博客网 时间:2024/05/16 19:34
L1-007. 念数字
输入一个整数,输出每个数字对应的拼音。当整数为负数时,先输出“fu”字。十个数字对应的拼音如下:
0: ling
1: yi
2: er
3: san
4: si
5: wu
6: liu
7: qi
8: ba
9: jiu
输入格式:
输入在一行中给出一个整数,如: 1234 。
提示:整数包括负数、零和正数。
输出格式:
在一行中输出这个整数对应的拼音,每个数字的拼音之间用空格分开,行末没有最后的空格。如 yi er san si。
输入样例:
-600
输出样例:
fu liu ling ling
#include <stdio.h>#include <stdlib.h>#include <string.h>int main(){ char *s[]={"ling","yi","er","san","si","wu","liu","qi","ba","jiu"}; //定义常量数组无需指明大小 int n,i,t,m; while(scanf("%d",&n)!=EOF) { int count[100]={0}; if(n<0) { printf("fu "); n=-n; } else if(n==0) { printf("ling\n"); continue; } for(i=0;n>0;i++) { t=n%10; count[i]=t; n=n/10; m=i; } printf("%s",s[count[m]]); for(i=m-1;i>=0;i--) { printf(" %s",s[count[i]]); } printf("\n"); } return 0;}
0 0
- L1-007. 念数字
- L1-007. 念数字
- L1-007. 念数字
- L1-007. 念数字
- L1-007. 念数字
- L1-007. 念数字
- L1-007. 念数字
- L1-007. 念数字
- L1-007. 念数字
- L1-007. 念数字
- L1-007. 念数字
- L1-007. 念数字
- L1-007. 念数字
- L1-007. 念数字
- L1-007. 念数字
- L1-007. 念数字 Java
- PAT L1-007. 念数字
- L1-007. 念数字(C++)
- MyBatis自动生成实体、DAO接口、Mapping映射文件
- Binary Tree Paths
- C语言基础笔记
- 【九度OJ】题目1195:最长&最短文本 解题报告
- LinkedHashMap和HashMap
- L1-007. 念数字
- 搭建SpringBoot-MyBatis-MyBatisGenerator项目
- [C语言]头文件之stdarg
- 女程序员中断一年半,难找工作
- BibTex相关
- 最优化问题综述
- vue学习笔记1
- How Many Answers Are Wrong hdu 3038 (带权并查集)
- Django-拆分model和view