瞎扯淡 计算某天是一年的第多少天

zsjacky · February 14, 2016 · Last by luikore replied at February 15, 2016 · 2484 hits

Python Programming: An Introduction to Computer Science 第 7 章第 15 题:

The days of the year are oftennumberedfrom 1 to through365(or 366). This number can be computed in three steps using int arithmetic: (a) dayNum=31*(month-1)+day (b) if the month is after February, subtract (4*month+23)/10 from dayNum (c) if it’s a leap year and after February 29, add 1

这个方法好巧妙,为什么第 2 步要那样算

1 Floor has deleted
You need to Sign in before reply, if you don't have an account, please Sign up first.