解题思路:
注意事项:
参考代码:
#include<iostream>
#include<string>
#include<algorithm>
#include<string>
#include <ctype.h>
using namespace std;
char a[21][10]={"zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven",
"twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen","twenty"};
void display(int k){
if(k<=20)
cout<<a[k];
else{
int n = k/10;
int m = k %10;
if(n == 2)
cout<<a[20];
else if(n == 3)
cout<<"thirty";
else if(n == 4)
cout<<"forty";
else
cout<<"fifty";
cout<<' '<<a[m];
}
}
int main(){
int h,m;
cin>>h>>m;
if(m == 0){
display(h);
cout<<" o'clock"<<endl;
}
else{
display(h);
cout<<" ";
display(m);
cout<<endl;
}
return 0;
}
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题6.8 (C++代码)浏览:575 |
printf基础练习2 (C语言代码)浏览:746 |
C语言程序设计教程(第三版)课后习题12.5 (C语言代码)浏览:764 |
多输入输出练习2 (C语言代码)浏览:1655 |
神奇的fans (C语言代码)浏览:980 |
班级人数 (C语言代码)浏览:922 |
母牛的故事 (C语言代码)浏览:478 |
C语言程序设计教程(第三版)课后习题3.7 (C语言代码)浏览:570 |
C语言程序设计教程(第三版)课后习题6.9 (C语言代码)浏览:479 |
非常简单的算法,题解1049:C语言程序设计教程(第三版)课后习题11.1 (C语言代码)浏览:608 |