题解 | #计算日期到天数转换#
计算日期到天数转换
https://www.nowcoder.com/practice/769d45d455fe40b385ba32f97e7bcded
def run(x): #判断是否闰年
flag = False
if (x%4 == 0) and (x%100 != 0):
flag = True
elif (x%4 != 0) and (x%400 == 0):
flag = True
return flag
def cal(x): #计算天数
a = list(map(int,x.split()))
pool = [[1,31],[2,28],[3,31],[4,30],[5,31],[6,30],[7,31],[8,31],[9,30],[10,31],[11,30],[12,31]]
day = 0
for i in range(1,a[1]):
day += pool[i-1][1]
day += a[2]
if run(a[0]):
day += 1
return day
while True:
try:
data = input()
print(cal(data))
except:
break

谷川联行工作强度 24人发布