什么是最简单的算法来找到一个给定的一年零一天的星期几? [英] What is the easiest algorithm to find the day of week of day zero of a given year?

查看:184
本文介绍了什么是最简单的算法来找到一个给定的一年零一天的星期几?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找出某一年零一天(1月1日)的一周中的一天。

I am trying to figure out what the day of the week of day zero (January 1st) of a given year.

到目前为止,我已经看过了维基百科页面计算周的一天,但我不知道是否有是一种最简单的算法,如果你只是想找到零一天。

So far I have looked at the Wikipedia page 'Calculating the day of the week' but I was wondering if there is an easiest algorithm if you're just trying to find day zero.

推荐答案

几年重复上一个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".

这篇关于什么是最简单的算法来找到一个给定的一年零一天的星期几?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆