# 打鱼还是晒网

``2012 10 25``

``sleeping``

``````#include <stdio.h>
#include <stdlib.h>

int main()
{
int a1,b,c,s=0,i;
int a[12]= {31,28,31,30,31,30,31,31,30,31,30,31};
scanf("%d%d%d",&a1,&i,&c);
if(a1%4==0&&a1%100!=0||a1%400==0)a[1]=29;
else a[1]=28;
for(b=0; b<i-1; b++)
s+=a[b];
s+=c;
i=s%5;
if(i<=3)printf("fishing\n");
else printf("sleeping\n");
return 0;
}
``````

``````#include <iostream>

using namespace std;

int leapYear(int year);  //闰年判断函数

int count(int year,int month,int day); //计算从1990.1.1号开始到当前日期的天数

int main()
{

int year,month,day;
cin>>year>>month>>day;

if(count(year,month,day)%5==4||count(year,month,day)%5==0)
cout<<"sleeping"<<endl;
else
cout<<"fishing"<<endl;

return 0;
}

int leapYear(int year)  //闰年判断函数
{
if((year%4==0&year%100!=0)||year%400==0)
return 1;
else
return 0;
}

int count(int year,int month,int day) //计算从1990.1.1号开始到当前日期的天数
{
int monthdays[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int days=0;
int i;
for(i=1990;i<year;i++)   //计算year之前的总天数
{
if(leapYear(i)==1)
days+=366;
else
days+=365;
}

for(i=1;i<month;i++)
days+=monthdays[i];

if(month>2&&leapYear(year)==1)
days++;

days+=day;

return days;
}
``````