• 分别输入某年某月某日,判断这一天是这一年的第几天?(考虑闰年)


    #方法一:
    # year = int(input("请输入年:"))
    # month = int(input("请输入月:"))
    # day = int(input("请输入日:"))
    # if month == 1:
    # count = day
    # elif month == 2:
    # count = 31 + day
    # elif (month >= 3) and ((year % 4 == 0 and year % 100 != 0) or year % 400 == 0):
    # if month == 3:
    # count = 31 + 29 + day
    # if month == 4:
    # count = 31 + 29 + 31 + day
    # if month == 5:
    # count = 31 + 29 + 31 + 30 + day
    # if month == 6:
    # count = 31 + 29 + 31 + 30 + 31 + day
    # if month == 7:
    # count = 31 + 29 + 31 + 30 + 31 + 30 + day
    # if month == 8:
    # count = 31 + 29 + 31 + 30 + 31 + 30 + 31 + day
    # if month == 9:
    # count = 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + day
    # if month == 10:
    # count = 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + day
    # if month == 11:
    # count = 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + day
    # if month == 12:
    # count = 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + day
    # else:
    # if month == 3:
    # count = 31 + 28 + day
    # if month == 4:
    # count = 31 + 28 + 31 + day
    # if month == 5:
    # count = 31 + 28 + 31 + 30 + day
    # if month == 6:
    # count = 31 + 28 + 31 + 30 + 31 + day
    # if month == 7:
    # count = 31 + 28 + 31 + 30 + 31 + 30 + day
    # if month == 8:
    # count = 31 + 28 + 31 + 30 + 31 + 30 + 31 + day
    # if month == 9:
    # count = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + day
    # if month == 10:
    # count = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + day
    # if month == 11:
    # count = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + day
    # if month == 12:
    # count = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + day
    #
    # print(year,'年第' + 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 = day
    # if (year % 4 == 0 and year % 100 != 0) or year % 400 == 0:
    # if month > 1 and month <= 12:
    # count = list[month - 2] + day
    # else:
    # if month > 1 and month <=12:
    # count = list[month - 2] + day - 1
    # print('第' + str(count) + '天')

    #方法三:
    # year = int(input("请输入年:"))
    # month = int(input("请输入月:"))
    # day = int(input("请输入日:"))
    # days = day
    # if month > 1:
    # days += 31
    # if month > 2:
    # if(year%4==0 and year%100!=0) or year%400==0:
    # days += 29
    # else:
    # days += 28
    # if month > 3:
    # days += 31
    # if month > 4:
    # days += 30
    # if month > 5:
    # days += 31
    # if month > 6:
    # days += 30
    # if month > 7:
    # days += 31
    # if month > 8:
    # days += 31
    # if month > 9:
    # days += 30
    # if month > 10:
    # days += 31
    # if month > 11:
    # days += 30
    # if month > 12:
    # days += 31
    # print("在",year,"第",days,"天")
    #
    #
    #
    耐得住寂寞,守得住繁华
  • 相关阅读:
    C# 委托应用总结
    C语言指针总结
    SQL2005四个排名函数(row_number、rank、dense_rank和ntile)的比较
    C#接口
    C# Linq
    C#反射
    重写与重载
    mysql01
    ajax
    bootstrap02导航菜单
  • 原文地址:https://www.cnblogs.com/yunzhongjunlang/p/13925812.html
Copyright © 2020-2023  润新知