-
Notifications
You must be signed in to change notification settings - Fork 0
/
Problem_019.c
58 lines (54 loc) · 985 Bytes
/
Problem_019.c
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <stdio.h>
#include <stdlib.h>
//A leap year occurs on any year evenly divisible by 4, but not on a century unless it is divisible by 400.
int main()
{
int months[12];
months[0] = 31;
months[1] = 28;
months[2] = 31;
months[3] = 30;
months[4] = 31;
months[5] = 30;
months[6] = 31;
months[7] = 31;
months[8] = 30;
months[9] = 31;
months[10] = 30;
months[11] = 31;
int year;
int days = 0;
int month = 0;
int times = 0;
for(month = 0; month < 12; month++)
{
days += mines[month];
}
days = days % 7;
if(days == 0)
{
times++;
}
for(year = 1901; year <= 2000; year++)
{
for(month = 0; month < 12; month++)
{
days = (days % 7);
if(days == 6)
{
times++;
printf("Month: %d Year: %d Day: %d\n", month, year, days);
}
if(month == 1 && year % 4 == 0 && year % 400 == 0 && year % 100 != 0)
{
days += months[month] + 1;
}
else
{
days += months[month];
}
}
}
printf("Result: %d\n", times);
return 1;
}