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

zsjacky · 2016年02月14日 · 最后由 luikore 回复于 2016年02月15日 · 2484 次阅读

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 楼 已删除
需要 登录 后方可回复, 如果你还没有账号请 注册新账号