# 打鱼还是晒网

``2002 10 23``

``小王今天打鱼``

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

typedef  struct DATE
{
int year;
int month;
int day;
}dates;

int Days(dates n)
{
int dayscounts[2][13]={{0,31,28,31,30,31,30,31,31,30,31,30,31},{0,31,29,31,30,31,30,31,31,30,31,30,31}};
int i,days=0,flag=0;
if((n.year%4==0&&n.year%100!=0)||(n.year%400==0))
flag=1;//flag==0则为平年，否则闰年
for(i=0;i<n.month;i++)
{
days+=dayscounts[flag][i];
}
for(i=1;i<=n.day;i++)
days++;
return days;

}

int main()
{
dates date;
dates flag;
int dayscount=0;
scanf("%d%d%d",&date.year,&date.month,&date.day);
flag.month=12;
flag.day=31;
for(int year=2000;year<date.year;year++)
{
flag.year=year;
dayscount+=Days(flag);
}
dayscount+=Days(date);

if(dayscount%5==4||dayscount%5==0)
printf("小王今天晒网\n");
else
printf("小王今天打鱼\n");

return 0;
}``````

``````#include <iostream>
using namespace std;
int main()
{
int y,m,d,sum=0,days;
cin>>y>>m>>d;//输入年、月、日，以分隔符(空格)分隔
int a[]={31,28,31,30,31,30,31,31,30,31,30,31};//平年每月天数
int b[]={31,29,31,30,31,30,31,31,30,31,30,31};//闰年每月天数
if(y%4==0&&y%100!=0||y%400==0)//y为闰年时
for(m-=2;m>=0;m-=1)
sum+=b[m];
else//y为平年时
for(m-=2;m>=0;m-=1)
sum+=a[m];
days=sum+d-1;//算出距离该年第一天的天数
int n=0;
for(int i=2000;i<y;i++)
{
if(i%4==0&&i%100!=0||i%400==0)
n+=366;
else
n+=365;
}
days+=n;//算出距离2000年1月1日的天数
if(days%5==0||(days-1)%5==0||(days-2)%5==0)//判断打鱼
cout<<"小王今天打鱼"<<endl;
if((days-3)%5==0||(days-4)%5==0)//判断晒网
cout<<"小王今天晒网"<<endl;
return 0;
}
``````