您的位置:首页 > 其它

An problem about date 根据年月日计算 星期几

2016-05-02 16:34 302 查看


/W = (d+2*m+3*(m+1)/5+y+y/4-y/100+y/400) mod 7(1、2月需要看作上一年的13、14月)

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<map>
#include<cctype>
#include<limits.h>
using namespace std;
int main()
{
int y, m, d, w;
while(scanf("%d%d%d",&y,&m,&d)!=EOF)
{
if(m < 3)
{
m += 12;
--y;
}
w =(d+2*m+3*(m+1)/5+y+y/4-y/100+y/400+1)%7;
printf("%d\n",w);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: