解题思路:平年2月28天,闰年2月29天,平年闰年分开考虑
注意事项: 无
参考代码:
y, m, d = map(int, input().split()) day_num = d year1 = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] year2 = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] # 判断平年闰年 if (y % 100 != 0 and y % 4 == 0) or y % 400 == 0: for i in range(m-1): day_num += year1[i] else: for i in range(m-1): day_num += year2[i] print(day_num)
0.0分
1 人评分