网易笔试-时钟

时钟

http://www.nowcoder.com/questionTerminal/72f3cc4658024d12bcc122c29b35394e

try:
    while True:
        #python 字符串为只读类型,借助helper
        def helper(time, scale):
            # 如果小时,分钟,秒分别大于'23'、'59'、'59',则置高位为'0'
            temp = []
            if time > scale:
                temp = list(time)
                temp[0] = '0'
                return ''.join(temp)
            else:
                return time
                
        T = int(input())
        while T > 0:
            t = input()
            time = t.split(':')
            res = []
            res.append(helper(time[0],'23'))
            res.append(helper(time[1],'59'))
            res.append(helper(time[2],'59'))
            
            print(':'.join(res))
            
            T -= 1
            
except:
    pass

全部评论

相关推荐

练习生懒羊羊:开飞机把这个公司创飞吧
点赞 评论 收藏
分享
05-29 20:34
门头沟学院 C++
KarlAllen:得做好直接春招的准备。学历差的话,一是面试要求会比学历好的严格不少,二是就算面试通过了也会被排序。总之暑期和秋招对于学历差的就是及其不友好
无实习如何秋招上岸
点赞 评论 收藏
分享
07-07 14:30
复旦大学 Java
遇到这种人我也不知道说啥了
无能的丈夫:但我觉得这个hr语气没什么问题啊(没有恶意
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务