解题思路:
先将构造20以内的英文字符串,再构造30、40、50的英文字符串,然后分解时和分输出。
注意事项:
整点(即分为0)输出o'clock!
参考代码:
#include<iostream> #include<string.h> using namespace std; char a[25][15]={"zero ","one ","two ","three ","four ","five ","six ","seven ","eight ","nine ","ten ","eleven ","twelve ","thirteen ","fourteen ","fifteen ","sixteen ","seventeen ","eighteen ","nineteen ","twenty "}; char b[6][10]={"","","twenty ","thirty ","forty ","fifty "}; void print(int n) { if(n<20){ cout<<a[n]; } else if(n%10==0){ cout<<b[n/10]; } else { cout<<b[n/10]; cout<<a[n%10]; } } int main() { int h,min; cin>>h>>min; if(min==0) { print(h); cout<<"o'clock"; } else{ print(h); print(min); } return 0; }
0.0分
1 人评分
点我有惊喜!你懂得!浏览:4111 |
C二级辅导-等差数列 (C语言代码)浏览:628 |
汽水瓶 (C语言代码)浏览:764 |
C语言程序设计教程(第三版)课后习题5.8 (C语言代码)浏览:806 |
钟神赛车 (C++代码)浏览:905 |
C二级辅导-统计字符 (C语言代码)浏览:528 |
C语言程序设计教程(第三版)课后习题5.6 (C语言代码)浏览:909 |
C语言程序设计教程(第三版)课后习题6.9 (C语言代码)浏览:1052 |
【计算直线的交点数】 (C语言代码)浏览:1501 |
C语言考试练习题_保留字母 (C语言代码)浏览:743 |