summaryrefslogtreecommitdiff
path: root/euler19.c
blob: 78a9d55773624c237c46212b0e64267d13ea6905 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <stdio.h>

const int days[2][12]={
	{31,28,31,30,31,30,31,31,30,31,30,31},
	{31,29,31,30,31,30,31,31,30,31,30,31}};

int isleap(int y)
{
	if (y%4==0 && (y%100!=0 || y%400==0))
		return 1;
	else
		return 0;
}

int main()
{
	int y,m,t;
	int d=1+365,count=0;
	for (y=1901;y<=2000;++y){
		t=isleap(y);
		for (m=0;m<12;++m){
			d%=7;
			if (d==0)
				++count;
			d+=days[t][m];
		}
	}
	printf("%d\n",count);
	return 0;
}