How to calculate the number of days between two given dates? (Leap year obstacle)

后端 未结 6 1061
情深已故
情深已故 2020-12-11 20:44
  • Any year evenly divisible by 400 is a leap year (e.g., 2000 was a leap year).
  • Any other year evenly divisible by 100 is not a leap year (e.g., 1700, 1800 and
6条回答
  •  感动是毒
    2020-12-11 21:12

    You don't need nested conditionals at all for this.

    Hint: instead of trying to determine whether a given year is a leap year, try to determine the total number of leap days that came before it.

提交回复
热议问题