三天打鱼,两天晒网问题
1、三天打鱼,两天晒网。从键盘任意输入一个年月日,时间范围(2005.1.1——2006.9.1),判断那天是打鱼还是晒网。
望高手指教~!
[此贴子已经被作者于2006-10-23 12:26:36编辑过]
#include<sio.h>
void main()
{
suct date today,term;
int yearday,year,day;
printf("Enter year/month/day:");
scanf("%d%d%d",&today.year,&today.month,&today.day); /*输入日期*/
term.month=12; /*设置变量的初始值:月*/
term.day=31; /*设置变量的初始值:日*/
for(yearday=0,year=1990;year<today.year;year )
{
term.year=year;
yearday =days(term); /*计算从1990年至指定年的前一年共有多少天*/
}
yearday =days(today); /*加上指定年中到指定日期的天数*/
day=yearday%5; /*求余数*/
if(day>0&&day<4) printf("he was fishing at that day.\n"); /*打印结果*/
else printf("He was sleeping at that day.\n");
}
[此贴子已经被作者于2006-10-23 18:42:49编辑过]