-
Notifications
You must be signed in to change notification settings - Fork 5
/
三天打鱼七天筛网.c
79 lines (75 loc) · 1.39 KB
/
三天打鱼七天筛网.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
三天打鱼两天晒网
*/
#include<stdio.h>
int leapYear(int year)
{
if((year%4==0&&year%100!=0)||(year%400==0))
{
return 1 ;
}
else
{
return 0 ;
}
}
int theDayOfMonth(int month,int isLeap)
{
if((month>=1) && (month <=7) && (month % 2 == 1))
{
return 31 ;
}
else if((month>7) && (month <=12) && (month % 2 == 0))
{
return 31 ;
}
else if((month == 2) && isLeap)
{
return 29 ;
}
else if((month == 2) && !isLeap)
{
return 28 ;
}
else
{
return 30;
}
}
int main()
{
int theSumOfDay = 0 ;
int month , year , remainder;
for( year = 1990 ; year < 2017 ; year ++ )
{
if(leapYear(year))
{
theSumOfDay = theSumOfDay + 366 ;
}
else
{
theSumOfDay = theSumOfDay + 365 ;
}
}
/*
for(i = 1 ; i <= 12 ; i ++)
{
printf("%d,%d\n",theDayOfMonth(i,1),theDayOfMonth(i,0));
}
*/
for( month = 1 ; month < 10 ; month ++)
{
theSumOfDay = theSumOfDay + theDayOfMonth(month,leapYear(2017)) ;
}
theSumOfDay = theSumOfDay + 15 ;
remainder = theSumOfDay % 5 ;
if( remainder <= 3 )
{
printf("打渔");
}
else
{
printf("晒网");
}
return 0 ;
}