解题思路:非常直白的一道题,按部就班地使用选择分支就行
注意事项:
1、审题!!!既然是简单模拟,就要想清楚具体步骤
2、善用复制粘贴,这样可以节省大量时间
参考代码:
#include<stdio.h>
void read_h(int h,int m);
void read_m(int m);
int main()
{
int h,m;
scanf("%d%d",&h,&m);
read_h(h,m);
if(m!=0)
read_m(m);
return 0;
}
void read_h(int h,int m)
{
switch(h){
case 0:printf("zero");break;
case 1:printf("one");break;
case 2:printf("two");break;
case 3:printf("three");break;
case 4:printf("four");break;
case 5:printf("five");break;
case 6:printf("six");break;
case 7:printf("seven");break;
case 8:printf("eight");break;
case 9:printf("nine");break;
case 10:printf("ten");break;
case 11:printf("eleven");break;
case 12:printf("twelve");break;
case 13:printf("thirteen");break;
case 14:printf("fourteen");break;
case 15:printf("fifteen");break;
case 16:printf("sixteen");break;
case 17:printf("seventeen");break;
case 18:printf("eighteen");break;
case 19:printf("nineteen");break;
case 20:printf("twenty");break;
case 21:printf("twenty one");break;
case 22:printf("twenty two");break;
case 23:printf("twenty three");break;
}
if(m==0)
printf(" o'clock");
}
void read_m(int m)
{
printf(" ");
if(m<=20)
switch(m){
case 0:printf("zero");break;
case 1:printf("one");break;
case 2:printf("two");break;
case 3:printf("three");break;
case 4:printf("four");break;
case 5:printf("five");break;
case 6:printf("six");break;
case 7:printf("seven");break;
case 8:printf("eight");break;
case 9:printf("nine");break;
case 10:printf("ten");break;
case 11:printf("eleven");break;
case 12:printf("twelve");break;
case 13:printf("thirteen");break;
case 14:printf("fourteen");break;
case 15:printf("fifteen");break;
case 16:printf("sixteen");break;
case 17:printf("seventeen");break;
case 18:printf("eighteen");break;
case 19:printf("nineteen");break;
case 20:printf("twenty");break;
}
else if(m>20)
{
int shi = m/10;
switch(shi){
case 2:printf("twenty");break;
case 3:printf("thirty");break;
case 4:printf("forty");break;
case 5:printf("fifty");break;
}
if(m%10!=0)
printf(" ");
switch(m%10){
case 1:printf("one");break;
case 2:printf("two");break;
case 3:printf("three");break;
case 4:printf("four");break;
case 5:printf("five");break;
case 6:printf("six");break;
case 7:printf("seven");break;
case 8:printf("eight");break;
case 9:printf("nine");break;
}
}
}
0.0分
0 人评分
C语言网提供由在职研发工程师或ACM蓝桥杯竞赛优秀选手录制的视频教程,并配有习题和答疑,点击了解:
一点编程也不会写的:零基础C语言学练课程
解决困扰你多年的C语言疑难杂症特性的C语言进阶课程
从零到写出一个爬虫的Python编程课程
只会语法写不出代码?手把手带你写100个编程真题的编程百练课程
信息学奥赛或C++选手的 必学C++课程
蓝桥杯ACM、信息学奥赛的必学课程:算法竞赛课入门课程
手把手讲解近五年真题的蓝桥杯辅导课程
发表评论 取消回复