参考代码:
#include<iostream> #include<string> using namespace std; int main() { int h, m; int h1, m1; cin >> h >> m; string time[21] = { "zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen","twenty" }; if (m == 0) h <= 20 ? cout << time[h] << " o'clock" << endl : cout << "twenty " << time[h % 20] << " o'clock" << endl; else { h <= 20 ? cout << time[h] : cout << "twenty " << time[h % 20]; if (m <= 20) cout << " " << time[m] << endl; else { switch (m/10) { case 2:cout << " twenty " << time[m % 10] << endl;break; case 3:cout << " thirty " << time[m % 10] << endl;break; case 4:cout << " forty " << time[m % 10] << endl;break; case 5:cout << " fifty " << time[m % 10] << endl;break; default: break; } } } return 0; }
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题8.3 (Java代码)浏览:1402 |
C语言训练-最大数问题 (C语言代码)浏览:648 |
C语言程序设计教程(第三版)课后习题11.5 (C语言代码)浏览:932 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:584 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:541 |
WU-蓝桥杯算法提高VIP-企业奖金发放 (C++代码)浏览:1267 |
WU-复数求和 (C++代码)浏览:2120 |
wu-理财计划 (C++代码)浏览:907 |
【魔板】 (C++代码)(时间超限,希望会的帮我改正一下)浏览:804 |
1126题解浏览:649 |