三天打渔,两天晒网c++程序源码

//文件名:fishing.cpp
//作者:Linx-huo
//版本:2017.1.1
//完成日期:2017.3.10
//实现功能:判断2010.01.01后的某天他是在打渔还是晒网
#include
int days(int year,int month,int day);
int main()
{
	int year,month,day;
	printf("请输入一个日期:\n");
	scanf("%d%d%d",&year,&month,&day);
    days(year,month,day);
	return 0;
}
    int days(int year,int month,int day)
{
	int n=0;                     //闰年个数
	int month1;                  //月数差
	int year_1;                  //年之差换算成天数差
    int month_1,day_1;
	int sum;                     //2010/01/后的天数
	int k;                       //求模数
    /*判断是否为闰年,并计算其个数*/
	int m;                       //计算闰年使用的参数
	int f1,f2,f3;
	for (m=2010;m<=year;m++)
	{
		f1=((m%4)==0);
		f2=((m%100)==0);
		f3=((m%400)==0);
		if(f1&&(!f2)||f2&&f3)
			n++;                //闰年个数
	}
	year_1=(year-2010)*365;7;
	/*计算月份差*/
	month1=month-1;
	switch(month1)
	{
	case 0:
		month_1=0;
		break;
	case 1:
		month_1=31;
		break;
	case 2:
	    month_1=59;
		break;
	case 3:
		month_1=90;
		break;
	case 4:
		month_1=120;
		break;
	case 5:
		month_1=151;
		break;
	case 6:
		month_1=181;
		break;
	case 7:
		month_1=212;
		break;
	case 8:
		month_1=243;
		break;
	case 9:
		month_1=273;
		break;
	case 10:
		month_1=304;
		break;
	case 11:
		month_1=334;
		break;
	}
	/*计算天数差*/
	day_1=day-1;
	sum=year_1+month_1+day_1;        //计算总天数  
	k=sum%5;                         //求模
	switch(k)
	{
	case 0:
		printf("今天该打渔\n");
		break;
	case 1:
		printf("今天该打渔\n");
		break;
	case 2:
		printf("今天该打渔\n");
		break;
	case 3:
		printf("今天该晒网\n");
		break;
	case 4:
		printf("今天该晒网\n");
		break;
	}
	return 0;
}

你可能感兴趣的:(三天打渔,两天晒网c++程序源码)