解题思路: 简单的判断语句,字典查询操作。 # 代码太冗长,适合初学者 d = {0: 'zero', 1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine', 10: 'ten', 11: 'eleven', 12: 'twelve', 13: 'thirteen', 14: 'fourteen', 15: 'fifteen', 16: 'sixteen', 17: 'seventeen', 18: 'eighteen', 19: 'nineteen', 20: 'twenty', 30: 'thirty', 40: 'forty', 50: 'fifty'} h, m = map(int, input().split()) # 输入 h1, m1 = 0, 0 # hour, minute = '', '' if 25 > h > 20: # 判断分 h1 = h % 20 hour = d[20] + ' ' + d[h1] else: hour = d[h] if 30 > m > 20: # 判断时 m1 = m % 20 minute = d[20] + ' ' + d[m1] elif 40 > m > 30: m1 = m % 30 minute = d[30] + ' ' + d[m1] elif 50 > m > 40: m1 = m % 40 minute = d[40] + ' ' + d[m1] elif 60 > m > 50: m1 = m % 50 minute = d[50] + ' ' + d[m1] else: minute = d[m] if m == 0: # 打印输出 print("{} o'clock".format(hour)) else: print('{} {}'.format(hour, minute))
0.0分
0 人评分
DNA (C语言代码)浏览:564 |
C语言程序设计教程(第三版)课后习题5.6 (C语言代码)浏览:594 |
Tom数 (C语言代码)浏览:517 |
1051(奇了怪了)浏览:747 |
C语言程序设计教程(第三版)课后习题10.2 (C语言代码)浏览:755 |
C二级辅导-求偶数和 (C语言代码)浏览:707 |
复数求和 (C语言代码)浏览:995 |
C语言程序设计教程(第三版)课后习题7.5 (C语言代码)浏览:712 |
C语言程序设计教程(第三版)课后习题7.3 (C语言代码)浏览:569 |
矩阵的对角线之和 (C语言代码)浏览:1401 |