题目如标题所示
//by GAIN_HZ
#include<stdio.h>
#include<string.h>
typedef struct date
{
int year;
int month;
int day;
} date; //定义日期结构体
int leap_year(int year) //判断是否是闰年
{
if( (year%4==0 && year%100!=0) || year%400==0 )
return 1;
return 0;
}
int count(date today)//计算天数
{
int permonth[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int total_days=0,year=0,month=0;
for( year=1990 ; year<today.year ; year++)//累计加到上一年 并且判断闰年
{
if(leap_year(year))//判断闰年
total_days+=366;
else
total_days+=365;
}
if(leap_year(today.year))//判断今年是否是闰年如果是,二月加一到29
permonth[2]++;
for( month=1 ; month<today.month ;month++) //累计加到上一个月
{
total_days+=permonth[month];
}
total_days+=today.day; //加这个月的天数
return total_days;//返回1990 1 1到今天所经历的天数
}
int FishNet(int total_days)//判断打鱼还是晒网
{
int result=total_days%5;
if( result>=1 && result<=3 )
return 1;
return 0;
}
int main()
{
date today;
int total_days;
scanf("%d %d %d", &today.year, &today.month, &today.day);//输入形式1990 1 1
total_days=count(today);//计算全部的天数,用于FishNet判断
if(FishNet(total_days))
printf("打鱼");
else
printf("晒网");
return 0;
}
是根据这位大佬的思路写的,程序内容也大差不差-点击这句话可以进入链接