文章
10
粉丝
253
获赞
8
访问
34.7k
一开始只通过50%的数据,一直找错误,发现逻辑没问题,但就是只过50%,代码如下:
class Data:
def __init__(self,year,month,day):
self.year = year
self.month = month
self.day = day
record = [0,31,28,31,30,31,30,31,31,30,31,30,31]
def main():
while True:
try:
year,month,day = map(int,(input().split(" ")))
if year<0:
print("Input error!")
return 0
if month>12 or month<1:
print("Input error!")
return 0
if year%400==0 or (year%4==0 and year%100!=0):
record[2] = 29
if day>record[month] or day<1:
print("Input error!")
return 0
he = 0
for i in range(1,month):
he = he+record[i]
print(he+day)
except:
break
if __name__ == '__main__':
main()
后来发现是多组输入的问题,我这里有return 0 ,有些多组输入就不支持了,好坑人,把return 0全部改成...
登录后发布评论
暂无评论,来抢沙发