题目:
等周末真的写不出来,再来看提问:),谢谢你~!
以下是我的代码(只做对题目所给的输入输出,其余答案错误):
try:
n = int(input())
mat = []
assert n != 0, "ErrorInput"
for row in range(n):
mat.append(list(map(int, input().split())))
for k in range(n):
try:
ans = 0
assert 0 < mat[k][1] <= 12, "ErrorInput"
assert 0 < mat[k][2] <= 31, "ErrorInput"
assert 0 <= mat[k][0], "ErrorInpout"
assert all(type(i) in (int, float) for i in mat[k]), "ErrorInput"
dic = {1: 31, 2: 28, 3: 31, 4: 30, 5: 31, 6: 30, 7: 31, 8: 31, 9: 30, 10: 31, 11: 30, 12: 31}
if mat[k][1] > 2:
for j in range(1, int(mat[k][1])):
ans = ans + dic[j]
ans = ans + mat[k][2]
if mat[k][0] % 400 == 0 or (mat[k][0] % 4 == 0 and mat[k][0] % 100 != 0):
ans = ans + 1
elif mat[k][1] == 2:
for j in range(1, 2):
ans += dic[j]
ans = ans + mat[k][2] - 1
elif mat[k][1] == 1:
if mat[k][2] == 1:
ans = 0
else:
ans = mat[k][2] - 1
print("Totaldays = {0}".format(ans))
except AssertionError as msg:
print("{0}".format(msg))
except ValueError:
print("ErrorInput")
except AssertionError as msg:
print("{0}".format(msg))