解题思路:确定好小时的范围,分钟的范围,整一个switch循环
期待更简洁的代码!!!!
参考代码:
#include <iostream>
using namespace std;
void display(int c)
{
switch(c)
{
case 0:cout<<"zero ";break;
case 1:cout<<"one ";break;
case 2:cout<<"two ";break;
case 3:cout<<"three ";break;
case 4:cout<<"four ";break;
case 5:cout<<"five ";break;
case 6:cout<<"six ";break;
case 7:cout<<"seven ";break;
case 8:cout<<"eight ";break;
case 9:cout<<"nine ";break;
case 10:cout<<"ten ";break;
case 11:cout<<"eleven ";break;
case 12:cout<<"twelve ";break;
case 13:cout<<"thirteen ";break;
case 14:cout<<"fourteen ";break;
case 15:cout<<"fifteen ";break;
case 16:cout<<"sixteen ";break;
case 17:cout<<"seventeen ";break;
case 18:cout<<"eighteen ";break;
case 19:cout<<"nineteen ";break;
case 20:cout<<"twenty ";break;
case 30:cout<<"thirty ";break;
case 40:cout<<"forty ";break;
case 50:cout<<"fifty ";break;
}
}
int main()
{
int h,m,a;
cin>>h>>m;
if(h<20)
{
display(h);
}else{
a=(h/10)*10;
display(a);
a=h%10;
display(a);
}
if(m==0)
{
cout<<"o'clock"<<endl;
}else if(m<=20||m==30||m==40||m==50)
{
display(m);
}else if(m>20)
{
a=(m/10)*10;
display(a);
a=m%10;
display(a);
}
return 0;
}
0.0分
3 人评分
【绝对值排序】 (C语言代码)浏览:499 |
C语言程序设计教程(第三版)课后习题8.4 (Java代码)浏览:788 |
小明A+B (C语言代码)浏览:1316 |
最长单词 (C语言代码)浏览:1474 |
输出正反三角形 (C语言代码)格式错误!!!浏览:1177 |
C语言程序设计教程(第三版)课后习题5.7 (Java代码)浏览:910 |
C语言训练-求1+2!+3!+...+N!的和 (C语言代码)浏览:821 |
三角形 (C++代码)递推浏览:825 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:645 |
循环入门练习6 (C语言代码)浏览:1058 |