代码拉取完成,页面将自动刷新
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
题目:输入某年某月某日,判断这一天是这一年的第几天?
程序分析:以3月5日为例,应该先把前两个月的加起来,
然后再加上5天即本年的第几天,
特殊情况,闰年的2月是29天,如果年份是闰年,并且闰年的
月份在3月以后,则需要多加1天。
每四年一次闰年。
1,3,5,7,8,10,12月是31天,2月是28天,其他的是30天。
"""
year = int (raw_input('year:\n'))
month = int (raw_input('month:\n'))
day = int (raw_input('day:\n'))
months = [0,31,59,90,120,151,181,212,243,273,304,334]
if 0<month<=12:
sum = months[month - 1]
else:
print 'data error'
sum += day
leap = 0
if (year % 400 == 0) or (year % 4 == 0) and (year % 100 != 0):
leap = 1
if (leap == 1) and (month >2):
sum += 1
print 'It is the %dth day.'% sum
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。