题解 | #计算日期到天数转换#

计算日期到天数转换

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

ys,ms,ds=input().split()
y=int(ys)
m=int(ms)
d=int(ds)
if y%100!=0 and y%4==0:
    if m==1:
        print(d)
    elif m==2:
        print(31+d)
    elif m==3:
        print(31+29+d)
    elif m==4:
        print(31+29+31+d)
    elif m==5:
        print(31+29+31+30+d)
    elif m==6:
        print(31+29+31+30+31+d)
    elif m==7:
        print(31+29+31+30+31+30+d)
    elif m==8:
        print(31+29+31+30+31++30+31+d)
    elif m==9:
        print(31+29+31+30+31++30+31+31+d)
    elif m==10:
        print(31+29+31+30+31++30+31+31+30+d)
    elif m==11:
        print(31+29+31+30+31++30+31+31+30+31+d)
    else:
        print(31+29+31+30+31++30+31+31+30+31+30+d)
elif y%100==0 and y%400==0:
    if m==1:
        print(d)
    elif m==2:
        print(31+d)
    elif m==3:
        print(31+29+d)
    elif m==4:
        print(31+29+31+d)
    elif m==5:
        print(31+29+31+30+d)
    elif m==6:
        print(31+29+31+30+31+d)
    elif m==7:
        print(31+29+31+30+31+30+d)
    elif m==8:
        print(31+29+31+30+31++30+31+d)
    elif m==9:
        print(31+29+31+30+31++30+31+31+d)
    elif m==10:
        print(31+29+31+30+31++30+31+31+30+d)
    elif m==11:
        print(31+29+31+30+31++30+31+31+30+31+d)
    else:
        print(31+29+31+30+31++30+31+31+30+31+30+d)
else:
    if m==1:
        print(d)
    elif m==2:
        print(31+d)
    elif m==3:
        print(31+28+d)
    elif m==4:
        print(31+28+31+d)
    elif m==5:
        print(31+28+31+30+d)
    elif m==6:
        print(31+28+31+30+31+d)
    elif m==7:
        print(31+28+31+30+31+30+d)
    elif m==8:
        print(31+28+31+30+31++30+31+d)
    elif m==9:
        print(31+28+31+30+31++30+31+31+d)
    elif m==10:
        print(31+28+31+30+31++30+31+31+30+d)
    elif m==11:
        print(31+28+31+30+31++30+31+31+30+31+d)
    else:
        print(31+28+31+30+31++30+31+31+30+31+30+d)
    

#最笨的方法,做完看其他人的解题策略,才知道我的又多笨...

全部评论

相关推荐

11-24 19:04
已编辑
湖南工商大学 Java
点赞 评论 收藏
分享
10-09 22:05
666 C++
找到工作就狠狠玩CSGO:报联合国演讲,报电子烟设计与制造
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务