资源描述:
《c语言万年历程序》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、#include#include#includeintleap(intyear);//判断是否为闰年intdays_month(intmonth,intyear);//判断这个月的天数intmenu_select();/*voidf(){intday,month,year,sum,leap,S;printf("请输入年月日");scanf("%d%d%d",&year,&month,&day);switch(month){case1:sum=0;break;case2:sum=31;break;case
2、3: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
3、
4、(year%4==0&&year%100!=0))l
5、eap=1;elseleap=0;if(leap==1&&month>2)sum++;S=(year-1+(year-1)/4-(year-1)/100+(year-1)/400+sum)%7;//X表示年份,C是该年份元旦开始到这一日的天数//S/7的系数就是星期数//01printf("%d",S);switch(S){case1:printf("星期一");break;case2:printf("星期二");break;case3:printf("星期三");break;case4:printf("星期四");break;case5:print
6、f("星期五");break;case6:printf("星期六");break;case0:printf("星期日");break;}}*/intLeap(intyear){intleap;if(year%400==0
7、
8、(year%4==0&&year%100!=0))leap=1;elseleap=0;returnleap;}intSU(intsum,intyear){intS;S=(year-1+(year-1)/4-(year-1)/100+(year-1)/400+sum)%7;returnS;}intSum(intyear,intmonth
9、,intday=1){intsum,leap;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:pri
10、ntf("dataerror");break;}sum=sum+day;leap=Leap(year);if(leap==1&&month>2)sum++;returnsum;}voidPrint(intS){switch(S){case1:printf("星期一");break;case2:printf("星期二");break;case3:printf("星期三");break;case4:printf("星期四");break;case5:printf("星期五");break;case6:printf("星期六");break;cas
11、e0:printf("星期日");break;}}voidFun1(){intday,month,year,sum,S;printf("请输入年月日");scanf("%d%d%d",&year,&month,&day);sum=Sum(year,month,day);S=SU(sum,year);Print(S);}voidFun2(){inti,j=1,k=1,a,b,month,year,sum;printf("输入年月:");scanf("%d%d",&year,&month);b=days_month(month,year);sum