资源描述:
《c语言万年历》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、C语言课程设计内容:课程设计题目:万年历功能如下:1、查询某年某月某日是星期几2、打印某年的某月的全月日历3、打印某年的全年日历4、退出具体要求:(1)在住菜单中输入1后,显示:“请输入年月日(XXXX,XX,XX)”运行后输出:XXXX年XX月XX日是星期X,是否继续查询(Y/N)?如果输入Y,则重新显示“请输入年月日(XXXX,XX,XX)”,否则回到主菜单.(2)在主菜单中输入2后,显示:“请输入要打印的月份(XXXX)”运行后输出X月的日历,格式为:XXXX年XX月SMTWTFSXXXXXXXXXXXXXXXXXXX
2、XXXXXXXXXXX(3)在主菜单中输入3后,显示:“请输入要打印的年份(XXXX)”运行后输出XXXX年的日历,XXXXX(月数)SMTWTFSXXXXXXXXXXXXXXXXXXXXXXXXXXXXxxSMTWTFSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX运行完成后显示:“是否继续打印(Y/N)?”如果输入Y,则重新显示“请输入要打印的年份(XXXX)”,否则回到主菜单。(4)在主菜单中输入4后,显示:“是否要真的退出(Y/N)?”如果输入Y,结束程序运行,否则重新显示主菜单。#include
3、tdio.h>#includetypedefstruct{intyear;charmonth;charday;}*DATE;DATENewDate(void);intDestroyDate(DATEdate);intDaysAMonth(DATEdate);intCheckDate(DATEdate);intSetDate(DATEdate,intyear,intmonth,intday);intGetWeek(DATEdate);intQueryDay(void);intShowMonth(DATEda
4、te);intQueryMonth(void);intQueryYear(void);intConfirmExit(void);intCalendar(void);intmain(){if(Calendar())return0;elsereturn1;}DATENewDate(void){DATEdate;date=(DATE)malloc(sizeof(*date));returndate;}intDestroyDate(DATEdate){if(!date)return0;free(date);return1;}intD
5、aysAMonth(DATEdate){intdays;if(!date)return0;switch(date->month){case1:case3:case5:case7:case8:case10:case12:days=31;break;case4:case6:case9:case11:days=30;break;default:days=0;break;}if(date->month==2)if(date->year%4==0&&date->year%400!=0
6、
7、date->year%400==0)days=2
8、9;elsedays=28;returndays;}intCheckDate(DATEdate){if(!date)return0;if(date->month<1
9、
10、date->month>12)return0;if(date->day<1
11、
12、date->day>DaysAMonth(date))return0;return1;}intSetDate(DATEdate,intyear,intmonth,intday){if(!date)return0;date->year=year;date->month=month;da
13、te->day=day;returnCheckDate(date);}intGetWeek(DATEdate){intyear,month,day;if(!date)return0;year=date->year;month=date->month;day=date->day;if(month<=2){month+=12;--year;}return(day+2*month+3*(month+1)/5+year+year/4-year/100+year/400)%7+1;}intQueryDay(void){DATEdate
14、;charcont;intyear,month,day;staticchar*week[]={"星期一","星期二","星期三","星期四","星期五","星期六","星期日"};if(!(date=NewDate()))return0;do{printf("请输入年月日(XXXX,XX,