雕刻时光

just do it……nothing impossible
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

蔡勒公式 知道年月日求星期几——pku3047

Posted on 2011-03-31 21:20  huhuuu  阅读(306)  评论(0编辑  收藏  举报
View Code
#include <stdio.h>
int main()
{
int year,month,day;
while(scanf("%d%d%d",&year,&month,&day)!=EOF)
{
if ( month < 3 )
{
year
-= 1;
month
+= 12;
}
char b[7][10] = {"sunday","monday","tuesday","wednesday","thursday","friday","saturday"};
int c = year/100, y = year - 100 * c;
int w = c/4 - 2*c +y+y/4 +(26 * (month + 1)/10 ) + day - 1;
w
= (w % 7+7)%7;//注意不然如2003 3 1会错,w可能为-22
printf("%s\n",b[w]);
}
}