100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > 题目:输入某年某月某日 判断这一天是这一年的第几天。

题目:输入某年某月某日 判断这一天是这一年的第几天。

时间:2021-05-29 00:55:26

相关推荐

题目:输入某年某月某日 判断这一天是这一年的第几天。

题目:输入某年某月某日,判断这一天是这一年的第几天。

方法一:year=int(input())month=int(input())day=int(input())if month==1:count=dayelif month==2:count = 31+dayelif (month>=3) and ((year % 4 == 0 and year % 100 != 0) or year % 400 == 0):if month==3:count = 31+29+dayif month==4:count = 31+29+31+dayif month == 5:count = 31 + 29 + 31 +30+ dayif month == 6:count = 31 + 29 + 31 +30+31+ dayif month == 7:count = 31 + 29 + 31 +30 +31+30+ dayif month == 8:count = 31 + 29 + 31 + 30 +31+30+31+dayif month == 9:count = 31 + 29 + 31 + 30 +31+30+31+31+dayif month == 10:count = 31 + 29 + 31 + 30 +31+30+31+31+30+dayif month == 11:count = 31 + 29 + 31 + 30 +31+30+31+31+30+31+dayif month == 12:count = 31 + 29 + 31 + 30 +31+30+31+31+30+31+30+dayelse:if month == 3:count = 31 + 28 + dayif month == 4:count = 31 + 28 + 31 + dayif month == 5:count = 31 + 28 + 31 + 30 + dayif month == 6:count = 31 + 28 + 31 + 30 + 31 + dayif month == 7:count = 31 + 28 + 31 + 30 + 31 + 30 + dayif month == 8:count = 31 + 28 + 31 + 30 + 31 + 30 + 31 + dayif month == 9:count = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + dayif month == 10:count = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + dayif month == 11:count = 31 + 28 + 31 + 30 +31+30+31+31+30+31+dayif month == 12:count = 31 + 28 + 31 + 30 +31+30+31+31+30+31+30+dayprint('第'+str(count)+'天')

方法二:year=int(input())month=int(input())day=int(input())list=[31,60,91,121,152,182,213,244,274,305,335,366]if month == 1:count = dayif (year % 4 == 0 and year % 100 != 0) or year % 400 == 0:if month > 1 and month<13:count = list[month-2] + dayelse:if month > 1 and month < 13:count = list[month - 2] + day-1print('第'+str(count)+'天')

运行结果:

1996

4

23

第114天<span lang="EN-US" style="" font-size:15.0pt;"="">

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。