#3
我写了个判定某一天在这一年中是第几天的程序,你在mian中稍做修改就可以实现了.
#include
#include
#include
struct date
{unsigned int year;
unsigned int mouth;
unsigned int day;
};
int rnian( unsigned int year)//判断是否闰年
{
int t;
if(year%4==0&&year%100!=0)return(t=1);
else if(year%400==0)return(t=1);
else return(t=0);
}
void main()
{
date date1;
int j;
cout<
cin>>date1.year>>date1.mouth>>date1.day;
cout<
if(rnian(date1.year)==1)
switch(date1.mouth)
{case 1:j=date1.day;break;
case 2:j=31+date1.day;break;
case 3:j=31+29+date1.day; break;
case 4:j=31+29+31+date1.day; break;
case 5:j=31+29+31+30+date1.day; break;
case 6:j=31+29+31+30+31+date1.day; break;
case 7:j=31+29+31+30+31+30+date1.day; break;
case 8:j=31+29+31+30+31+30+31+date1.day; break;
case 9:j=31+29+31+30+31+30+31+31+date1.day; break;
case 10:j=31+29+31+30+31+30+31+31+30+date1.day; break;
case 11:j=31+29+31+30+31+30+31+31+30+31+date1.day; break;
case 12:j=31+29+31+30+31+30+31+31+30+31+30+date1.day; break;
}
else
switch(date1.mouth)
{case 1:j=date1.day;break;
case 2:j=31+date1.day;break;
case 3:j=31+28+date1.day; break;
case 4:j=31+28+31+date1.day; break;
case 5:j=31+28+31+30+date1.day; break;
case 6:j=31+28+31+30+31+date1.day; break;
case 7:j=31+28+31+30+31+30+date1.day; break;
case 8:j=31+28+31+30+31+30+31+date1.day; break;
case 9:j=31+28+31+30+31+30+31+31+date1.day; break;
case 10:j=31+28+31+30+31+30+31+31+30+date1.day; break;
case 11:j=31+28+31+30+31+30+31+31+30+31+date1.day; break;
case 12:j=31+28+31+30+31+30+31+31+30+31+30+date1.day; break;
}
cout<
}
在cout后加一句:if ((j%5==1)||(j%5==2)||(j%5==3))输出那天在打鱼的信息,else输出在晒网的信息.