题解 | #计算日期到天数转换#这个速度好像不快

计算日期到天数转换

http://www.nowcoder.com/practice/769d45d455fe40b385ba32f97e7bcded

while True:

try:
    year, month, day = [int(i) for i in input().split()]
    total_days = day
    
    for i in range(2, month + 1):
        if i == 3:
            if year % 4 == 0 and year % 100 != 0:
                total_days += 29
            else:
                total_days += 28
        elif i in [2, 4, 6, 8, 9, 11]:
            total_days += 31
        else:
            total_days += 30
            
    print(total_days)

except:
    break
全部评论
为啥range(2, month + 1) 从2开始循环呢
点赞 回复 分享
发布于 2022-12-14 21:54 陕西

相关推荐

点赞 评论 收藏
分享
牛客83700679...:简历抄别人的,然后再投,有反馈就是简历不行,没反馈就是学历不行,多投多改只要技术不差机会总会有的
点赞 评论 收藏
分享
评论
8
6
分享

创作者周榜

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