题解 | #计算日期到天数转换#
计算日期到天数转换
https://www.nowcoder.com/practice/769d45d455fe40b385ba32f97e7bcded
while True:
try:
s = input().split()
year, month, day = int(s[0]), int(s[1]), int(s[2])
s1 = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
s2 = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
if year%4 == 0 and year%100 != 0 or year%400 == 0:
print(sum(s2[:month-1]) + day)
else: print(sum(s1[:month-1]) + day)
except:
break

查看13道真题和解析

