打鱼晒网
//打鱼晒网
#include<stdio.h>
int leap(int year)
{
int lp;
if((year%4==0&&year%100!=0)||year%400==0)
lp=1;
else
lp=0;
return lp;
}
int a[]={31,28,31,30,31,30,31,31,30,31,30,31};
int main()
{
int year,month,day;
int totalday=0;
int flag;
int i=1;//不要放在scanf语句下面,会报未定义i
printf("Input year month day with a blank:");
scanf("%d %d %d",&year,&month,&day);
for(;i<month;i++)
{
if(month>2&&leap(year))
a[1]=29;
totalday+=a[i-1];
}
totalday+=day;
for(i=1990;i<year;i++)
if(leap(i))
totalday+=366;
else
totalday+=365;
flag=totalday%5;
switch(flag)
{
case 1:
case 2:
case 3: printf("He is fishing that day\n");break;
case 0:
case 4:printf("He is basking that day\n");break;
default: printf("ERROR!");break;
}
return 0;
}
作者:火星十一郎
本文版权归作者火星十一郎所有,欢迎转载和商用,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利.