解题思路:
具体情况具体分析喽
(没写注释,欢迎大家找毛病,有好的建议 请告知。谢谢!)
注意事项:
特殊情况和格式吧
参考代码:
#include<stdio.h>
void clock(int n)
{
switch(n)
{
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;
default: break;
}
}
void clock2(int m)
{
switch(m)
{
case 2:printf("twenty");break;
case 3:printf("thirty");break;
case 4:printf("forty");break;
case 5:printf("fifty");break;
default: break;
}
}
void Main(int h,int m)
{
clock(h);
if(m==0)
{
printf("o'clock");
}
else if(m%100<=20)
clock(m);
else if(m%10!=0)
{
clock2(m/10);
printf(" ");
clock(m%10);
}
else
clock2(m/10);
}
int main()
{
int h,m;
scanf("%d%d",&h,&m);
if(h<=23&&h>=0)
{
if(m<60&&m>=0)
{
Main(h,m);
}
}
return 0;
}
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题6.3 (C语言代码)浏览:553 |
C语言程序设计教程(第三版)课后习题9.2 (Java代码)浏览:696 |
C语言程序设计教程(第三版)课后习题6.8 (C++代码)浏览:614 |
C语言程序设计教程(第三版)课后习题5.4 (C语言代码)浏览:821 |
A+B for Input-Output Practice (V) (C语言代码)浏览:497 |
模拟计算器 (C++代码)浏览:885 |
数字游戏 (C++代码)浏览:1240 |
2005年春浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:636 |
单词个数统计 (C语言代码)浏览:1046 |
输出九九乘法表 (C语言代码)浏览:1172 |