Commit bba1bfda by BellCodeEditor

auto save

parent 165dc3c6
Showing with 23 additions and 0 deletions
#输入“年月日”,输出是一年中的第几天
## 输入年月日,判断是一年的多少天
def getN(year,month,day):
sum = 0 ## 到最后在判断是闰年还是平年
for i in range(0,month):
sum += m[i]
sum += day
if (year%400==0) or (year%4==0 and year%10!=0 ): ## 表示是闰年
sum += 1
return sum
year = input("year : ") ## 输出数据
month = input("month : ")
day = input("day : ")
m = [0,31,28,31,30,31,30,31,31,30,31,30] ## 只包括前 11 个月
year = int(year)
month = int(month)
day = int(day)
print( getN(year,month,day))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment