首页 > 其他 > 详细

The Time in Words

时间:2015-05-17 11:56:10      阅读:238      评论:0      收藏:0      [点我收藏+]
 1 def main():
 2     time = ["one", "two", "three", "four", "five", "six", "seven", "eight","nine", 
 3        "ten", "eleven", "twelve", "thirteen", "fourteen", "quarter", "sixteen",
 4        "seventeen", "eighteen", "nineteen", "twenty", "twenty one", 
 5        "twenty two", "twenty three", "twenty four", "twenty five", 
 6        "twenty six", "twenty seven", "twenty eight", "twenty nine", "half"]
 7 
 8     h = int(raw_input())
 9     m = int(raw_input())
10     
11     msg = ""
12 
13     if h > 12:
14         h = h - 12
15         
16     if m == 0:
17         msg = time[h-1] + " o‘ clock"
18     elif m <= 30:
19         if m == 1:
20             msg = time[m-1] +  minute past  + time[h-1]
21         elif m == 15 or m == 30:
22             msg = time[m-1] +  past  + time[h-1]
23         else:
24             msg = time[m-1] +  minutes past  + time[h-1]
25     else:
26         m = 60 - m
27         if m == 15:
28             msg = time[m-1] +  to  + time[h]
29         else:
30             msg = time[m-1] +  minutes to  + time[h]
31 
32     print msg
33 
34 
35 main()

 

Link:

  https://www.hackerrank.com/challenges/the-time-in-words

学习

  预定义

  关键

    精确的情况分类和判断

 

The Time in Words

原文:http://www.cnblogs.com/sangocare/p/4509228.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!