解题思路:
注意事项:输入中间有空格,思路很简单,分情况就行了,然后直接读取相应数字的字符串。
参考代码:
#include<bits/stdc++.h> using namespace std; char t[30][10] = { "zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen","twenty","thirty","forty","fifty","sixty" }; int main() { int h,m; scanf("%d %2d", &h, &m); int temh = 0; int tem = 0; if (m == 0) cout <<t[h]<<" "<<"o'clock"<<endl; else { if (h > 20) { h = h % 10; cout << "twenty" << " " << t[h]; } else cout << t[h]; if (m > 20) { tem = (m / 10)*10; if (tem == 30) tem = 21; else if (tem == 40) tem = 22; else if (tem == 50) tem = 23; else if (tem == 60) tem = 24; m = m % 10; cout <<" "<<t[tem]; if(m!=0)cout <<" "<< t[m]; } else cout << " " << t[m]; } }
0.0分
2 人评分
C二级辅导-公约公倍 (C语言代码)浏览:1508 |
回文数(一) (C语言代码)浏览:728 |
C语言程序设计教程(第三版)课后习题6.9 (C语言代码)浏览:532 |
C语言程序设计教程(第三版)课后习题8.3 (C语言代码)浏览:563 |
母牛的故事 (C语言代码)浏览:1427 |
Minesweeper (C语言描述,蓝桥杯)浏览:1122 |
2^k进制数 (C语言描述,蓝桥杯)浏览:1420 |
蚂蚁感冒 (C语言代码)浏览:768 |
C二级辅导-分段函数 (C语言代码)浏览:593 |
筛排处理 (C语言代码)浏览:782 |