1万年历的设计:要求:模仿现实生活中的挂历,能够显示年历、月历、日历,并具备退出功能。当前页以系统当前日期的月份为准显示当前月的每一天(显示出日及对应的星期几)。当系统日期变到下一月时,系统自动翻页到下一月。万年历的程序流程图:主要程序流程图:具体对于月份和年份的程序图如下:Memu-slect()=1Printf(“输入年月日计算星期”)开始Memu-slect()=2Memu-slect()=3Memu-slect()=4Printf(“输入年月日计算星期”)Printf(“输入年月日计算星期”)Printf(“输入年月日计算星期”)结束23上图为计算星期方法上图为打印日历程序图4万年历的设计的程序源代码:#includestdio.h#includestdlib.h#includectype.hvoidf(){intday,month,year,sum,leap,S;printf(\n请输入年月日\n);scanf(%d%d%d,&year,&month,&day);while(1){if((month12||month1)||(day31||day1)){printf(输入错误,重新输入);scanf(%d%d%d,&year,&month,&day);}elsebreak;}switch(month){case1:sum=0;break;case2:sum=31;break;case3:sum=59;break;case4:sum=90;break;case5:sum=120;break;case6:sum=151;break;case7:sum=181;break;case8:sum=212;break;case9:sum=243;break;case10:sum=273;break;case11:sum=304;break;case12:sum=334;break;default:printf(dataerror);break;}sum=sum+day;if(year%400==0||(year%4==0&&year%100!=0))leap=1;elseleap=0;if(leap==1&&month2)sum++;S=(year-1+(year-1)/4-(year-1)/100+(year-1)/400+sum)%7;switch(S)5{case1:printf(星期一\n);break;case2:printf(星期二\n);break;case3:printf(星期三\n);break;case4:printf(星期四\n);break;case5:printf(星期五\n);break;case6:printf(星期六\n);break;case0:printf(星期日\n);break;}}voidg(){inti,j=1,k=1,a,b,month,year;printf(\n输入年月:\n);scanf(%d%d,&year,&month);while(1){if(month12||month1){printf(输入错误,重新输入);scanf(%d%d,&year,&month);}elsebreak;}b=days_month(month,year);a=firstday(month,year);printf(*************************************\n);printf(SunMonTueWedThuFriSat\n);if(a==7){for(i=1;i=b;i++){printf(%4d,i);if(i%7==0){printf(\n);}}}if(a!=7){while(j=4*a){printf();j++;}for(i=1;i=b;i++){printf(%4d,i);if(i==7*k-a)6{printf(\n);k++;}}}printf(\n*************************************\n);printf(\n);}intleap(intyear){if(year%4==0&&year%100!=0||year%400==0)return1;elsereturn0;}intdays_month(intmonth,intyear){if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)return31;if(month==4||month==6||month==9||month==11)return30;if(month==2&&leap(year)==1)return29;elsereturn28;}intfirstday(intmonth,intyear){intW;W=(1+2*month+3*(month+1)/5+year+year/4+year/400-year/100)%7+1;returnW;}voidh(){inti,j=1,k=1,a,b,month,year,g;printf(\n输入任意年:\n);scanf(%d,&year);for(g=0;g=11;g++){month=g+1;b=days_month(month,year);a=firstday(month,year);printf(%d月\n,month);printf(*************************************\n);printf(SunMonTueWedThuFriSat\n);if(a==7){for(i=1;i=b;i++)7{printf(%4d,i);if(i%7==0){printf(\n);}}}j=1;k=1;if(a!=7){while(j=4*a){printf();j++;}for(i=1;i=b;i++){printf(%4d,i);if(i==7*k-a){printf(\n);k++;}}}printf(\n*************************************\n);printf(\n);}}voidmain(){for(;;){switch(menu_select()){case1:printf(输入年月日计算星期几\n);f();break;case2:printf(打印任意日历\n);g();break;case3:printf(打印任意年历\n);h();break;case4:printf(谢谢使用!\n);exit(0);}}8}intmenu_select(){charS;intcn;printf(1.输入年月日计算星期几\n);printf(2.打印任意月历\n);printf(3.打印任意年历\n);printf(4.谢谢使用!\n);printf(input1-4:\n);do{S=getchar();cn=(int)S-48;}while(cn0||cn6);returncn;}万年历的运行结果截图万年历的日历功能的实现:月历功能的实现:9年历功能的实现:1011