# 九度OJ 题目1043：Day of Week

int dayofweek(int y, int m, int d) /* 0 = Sunday */
{
static int t[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4};
y -= m < 3;
return (y + y/4 - y/100 + y/400 + t[m-1] + d) % 7;
}

AC代码如下：

#include <stdio.h>

int dayofweek(int y, int m, int d) /* 0 = Sunday */
{
static int t[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4};
y -= m < 3;
return (y + y/4 - y/100 + y/400 + t[m-1] + d) % 7;
}

const char day[][20] = {"Sunday","Monday","Tuesday","Wednesday",
"Thursday","Friday","Saturday"};

const char month[][20] = {"January", "February", "March", "April",
"May", "June", "July", "August", "September",
"October", "November", "December"};

int main()
{
char m[20];
int d,y,mon;
int i;
while(scanf("%d %s %d",&d,m,&y) != EOF)
{
for(i = 0;i < 12;i++)
{
if(strcmp(m,month[i]) == 0)
{
mon = i;
break;
}
}
//printf("%d %d %d\n",y,mon + 1,d);
printf("%s\n",day[dayofweek(y,mon + 1,d)]);
}
return 0;
}

• 本文已收录于以下专栏：

## 题目1043：Day of Week

import java.io.IOException; import java.util.Scanner; import java.io.FileReader; import java.io.Buff...

## 九度 oj 题目1446：Head of a Gang

http://ac.jobdu.com/problem.php?pid=1446 参考了 http://blog.csdn.net/jdplus/article/details/19759729 并...

## 九度OJ 题目1446：Head of a Gang

• lhyer
• 2015年08月10日 14:58
• 564

举报原因： 您举报文章：九度OJ 题目1043：Day of Week 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)