且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

什么是最简单的算法来找到一个给定的一年零一天的星期几?

更新时间:2023-11-27 16:01:10

几年重复上一个28年的周期。天-的周(天 - - 的周中的值被存储在一个阵列/载体)28除以年,并返回各自的。这将是的的最快,最简单的算法。但是,这种算法也不会完全清楚的人阅读code。您的选择取决于你是否想快速,简单或显然是正确的。

Years repeat on a 28 year cycle. Divide the year by 28 and return the respective day-of-the-week (the day-of-the-week values being stored in an array/vector). This would be the fastest and simplest algorithm. But this algorithm would not be at all clear to someone reading the code. Your choice depends on whether you want fast, simple or "clearly correct".