资源描述:
《C语言实训--万年历源代码.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、#include#include#include#include#include#defineYEAR365intnumday[2][12]={{31,28,31,30,31,30,31,31,30,31,30,31},{31,29,31,30,31,30,31,31,30,31,30,31}};intleap(intyear);intcalday(inty,intm);intcounterdays(in
2、tyear,intmonth,intday);intweek(intyear,intmonth,intday);inteachyeartotal(intyear,intmonth,intday);intmaxDay(inty,intmonth);voidprint(inty,intm,intw);voidfestival(intyear,intmonth,intday);intIsLeap(inty);intguanli(inti);voidrili(intyear,intmonth);intr
3、ili1();voidrili2();voidrili3();voidrili4();voidrili5();voidfan();voidshow(intyear,intmonth,intdate,intsec,intmini,inthour);intmain(){inti;printf("***************************************");printf("1.查询日历,输入年份:");printf("2.查询该月日历及对应星期,输入年份和月份:");
4、printf("3.查询星期几及节日,输入年月日:");printf("4.距您输入日期还有多少天,输入日期:");printf("5.通过键盘上下控制不同年月日:");scanf("%d",&i);guanli(i);return0;}intguanli(inti){switch(i){case1:rili1();returnmain();case2:rili2();returnmain();case3:rili3();returnmain();case4:rili4();retu
5、rnmain();case5:rili5();returnmain();}return0;}intrili1(){intyear;intn,i;printf("输入年份:");scanf("%d",&year);printf("thecalendaroftheyear%d",year);printf("");printf("=============================");for(i=1;i<13;i++){printf("%d月份",i);rili(year,i)
6、;}n=leap(year);return0;}voidrili2(){intyear,month,w;printf("输入年月:");scanf("%d%d",&year,&month);w=calday(year,month);print(year,month,w);}voidrili3(){intyear,month,day,number;printf("输入年月日:");scanf("%d%d%d",&year,&month,&day);festival(year,month,day);
7、number=week(year,month,day);printf("星期%d",number);}voidrili4(){intyear,month,day;printf("输入年月日:");scanf("%d%d%d",&year,&month,&day);eachyeartotal(year,month,day);counterdays(year,month,day);}voidrili5(){intyear,month,date,sec,mini,hour;fan();show(yea
8、r,month,date,sec,mini,hour);}intleap(intyear){intn=(year%4==0&&year%100!=0
9、
10、year%100!=0);returnn;}voidrili(intyear,intmonth){inti,day,first_day,flag,year1,year2;inttemp=6;flag=leap(year);year1=year/100;year2=year%100;if(year>2000){year1=year1-20;day=