综合性程序设计报告设计题目:万年历指导教师:班级:学号:_设计者:成绩:设计时间:2012年6月8日[题目描述]用于利用计算机实现万年历功能,包括日期对星期的转换,根据指定日期对N天后是什么日期的计算。和显示当前日期,纪念日提醒等功能。主要功能:1.日期推算2.日期显示3.纪念日提醒[功能模块分解及说明]根据题目要求,可以用结构体实现,这个系统可以分为:年历显示、月历查询、日期查询和日期推算四个部分。其中在日期查询中包括纪念日提醒。(1)主函数main()主函数利用while(1)循环使得执行完每个部分之后还能回到主菜单,并利用switch函数当输入不同的值时调用不同的模块。主函数如下:voidmain()/*主函数*/{intyear,month,day,select;while(1){dushijian();printf(\n);getmenu();printf(请输入相应数字:);/*菜单选择*/scanf(%d,&select);system(cls);switch(select){case1:/*当选择为1时显示年历*/printf(年历显示:输入年(如2011):);scanf(%d,&year);if(year0&&year10000)/*显示年份从0-10000*/{display1(year);/*调用函数*/printf(提示按↑:上一年按↓:下一年按其他键:返回菜单\n\n);setDay1(year,month,day);}elsesystem(cls);/*清屏*/printf(输入无效,重新输入!\n);break;case2:/*当选择为2显示月历*/printf(月历显示:输入年月(如2011,6):);scanf(%d,%d,&year,&month);if(year0&&year10000&&month=1&&month=12){display2(year,month);printf(提示按←:上个月按→:下个月按其他键:返回菜单\n\n);setDay2(year,month,day);}elsesystem(cls);printf(输入无效,重新输入!\n);break;case3:/*当选择为3时显示日期*/printf(日期显示:输入年月日(比如2011,6,23):);scanf(%d,%d,%d,&year,&month,&day);if(year0&&year10000&&month=1&&month=12&&day=1&&day=maxDay(year,month)){display3(year,month,day);printf(提示按PageUp:前一天按PageDown:后一天按其他键:返回菜单\n\n);setDay3(year,month,day);}elsesystem(cls);printf(输入无效,重新输入!\n);break;case4:/*当选择4时为日期推算*/riqituisuan();break;case5:exit(0);default:/*当输入其他数字时,输入无效,重新输入*/system(cls);printf(输入无效,重新输入!\n);}}}(2)年历显示用来显示某一年的日历。voiddisplay1(intyear)/*输出年历*/{inti;printf(\n);for(i=1;i=12;i++){printf(%d年%d月\n\n,year,i);display(year,i);}}voiddisplay(intyear,intmonth)/*输出年月*/{intmax,number,i,j=1;max=maxDay(year,month);number=week(year,month,1);printf(%4s%4s%4s%4s%4s%4s%4s\n,Sun,Mon,Tue,Wed,Thu,Fri,sat);for(i=0;inumber;i++)printf();/*1号前的星期补空格*/while(j=max){printf(%6d,j);if(i%7==6)printf(\n);/*每7格换一行*/i++;j++;}printf(\n\n);}(3)输出月历voiddisplay2(intyear,intmonth)/*输出月历*/{printf(\n%d年%d月\n,year,month);display(year,month);}voiddisplay(intyear,intmonth)/*输出年月*/{intmax,number,i,j=1;max=maxDay(year,month);number=week(year,month,1);printf(%4s%4s%4s%4s%4s%4s%4s\n,Sun,Mon,Tue,Wed,Thu,Fri,sat);for(i=0;inumber;i++)printf();/*1号前的星期补空格*/while(j=max){printf(%6d,j);if(i%7==6)printf(\n);/*每7格换一行*/i++;j++;}printf(\n\n);}(4)日期查询voiddisplay3(intyear,intmonth,intday)/*输出日历*/{whatweek(year,month,day);jieri(month,day);counterdays(year,month,day);}intcounterdays(intyear,intmonth,intday)/*判断今天距特定日期的天数*/{intyear1,days0,days1,month1,days,day1;time_ttimep;structtm*p;time(&timep);p=gmtime(&timep);year1=(1900+p-tm_year);month1=(1+p-tm_mon);day1=(p-tm_mday);/*获取系统时间year1、month1、day1分别为年、月、日*/days0=(year-1)*365+(year-1)/4-(year-1)/100+(year-1)/400+eachyeartotal(year,month,day);days1=(year1-1)*365+(year1-1)/4-(year1-1)/100+(year1-1)/400+eachyeartotal(year1,month1,day1);days=days0-days1;/*计算出两个日期之间的时间差*/printf(\n今天距%d年%d月%d日还有%d天\n\n,year,month,day,days);returndays;}voidwhatweek(intyear,intmonth,intday)/*判断是星期几*/{intnumber;number=(year-1)+(year-1)/4-(year-1)/100+(year-1)/400+eachyeartotal(year,month,day);number=number%7;switch(number){case0:printf(\n%d年%d月%d日是星期日,year,month,day);break;case1:printf(\n%d年%d月%d日是星期一,year,month,day);break;case2:printf(\n%d年%d月%d日是星期二,year,month,day);break;case3:printf(\n%d年%d月%d日是星期三,year,month,day);break;case4:printf(\n%d年%d月%d日是星期四,year,month,day);break;case5:printf(\n%d年%d月%d日是星期五,year,month,day);break;case6:printf(\n%d年%d月%d日是星期六,year,month,day);break;default:system(cls);printf(出现错误!\n);}}voidjieri(intmonth,intday)/*判断是否公历节日*/{if(month==1)switch(day){case1:printf(,这天是元旦);}if(month==2)switch(day){case14:printf(,这天是情人节);}if(month==3)switch(day){case8:printf(,这天是妇女节);break;case12:printf(,这天是植树节);}if(month==4)switch(day){case1:printf(,这天是愚人节);}if(month==5)switch(day){case1:printf(,这天是劳动节);break;case4:printf(,这天是青年节);}if(month==6)switch(day){case1:printf(,这天是儿童节);}if(month==7)switch(day){case1:printf(,这天是建党节);}if(month==8)switch(day){case1:printf(,这天是建军节);}if(month==9)switch(day){case10:printf(,这天是教师节);}if(month==10)switch(day){case1:printf(,这天是国庆节);}}(5)日期推算if(((info/10000000)=9)&&(info/10000000)0){xyear=info/10000;xmonth=(info-xyear*10000)/100;xday=info-xyear*10000-xmonth*100;printf(您要查询的是%d年%d月%d日。\n,xyear,xmonth,xday);counter=getwDay(xyear,xmonth,xday);printf(%d年%d月%d日是星期,xyear,xmonth,xday);if(counter==0){counter=7;}printf(%d\n,counter);day_differ=The_day(xyear,xmonth,xday);printf(距离今天相差%d天\n,day_differ);}}intThe_day(intyear,intmonth,intday)/*判断要查询的日期据今天的时间*/{intYear,Month,Day,flag,i,q;longsum=0;structtm*gmt=getDay();Year=gmt-tm_year+1900;/*系统当前年*/Month=gmt-tm_mon+1;/*系统的当前月份*/Day=gmt-tm_mday;/*系统当前天*/if(year!=Year){if(yearYear){q=year;year=Year;Year=q;q=month;month=Month;Month=month;q=day;day=Day;Day=day;}for(i=year;iYear;i++){flag=checkYear(i);if(flag==1){sum=sum+366;}else{sum=sum+365;}}flag=checkYear(year);for(i=1;imonth;i++){sum=sum-daysOfMonth[flag][i-1];}sum=sum-day;flag=checkYear(Year);for(i=Month-1;i=1;i--){sum=sum+daysOfMonth[flag][i-1];}sum=sum+Day;}elseif(year==Year){flag=checkYear(year);if(month!=Month){if(monthMonth){q=month;month=Month;Month=q;q=day;day=Day;Day=