资源描述:
《万年历打印系统(c语言程序).doc》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、#include#include#include#includevoidyi_nian();//输出当年日历intleap(intyear);//判断给定年份是否是闰年longintf(intyear,intmonth);longintg(intmonth);longintn(intyear,intmonth,intday);intw(intyear,intmonth,intday);voidch_month_1(inti);//用switch语句将数字转化为英文intYi_yue_time(
2、);//输出当月日期及当天时间voidgetcl(inta[]);//计算当天时间voidprintcal(inta[]);//计算当月日期intdate[12][6][7];intday_tbl[][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}};FILE*fp;intmain(){yi_nian();Yi_yue_time();return0;}//输出当年日历voidyi_nian(){intb[7];intsw,leap,i,j,k,wd,da
3、y;intyear;chartitle[]="SUMMONTUEWEDTHUFRISAT";getcl(b);fp=fopen("D:\rili.txt","w+");if(!fp){printf("filecannotbeopened");exit(0);}year=b[0];sw=w(year,1,1);leap=year%4==0&&year%100
4、
5、year%400==0;for(i=0;i<12;i++)for(j=0;j<6;j++)for(k=0;k<7;k++)date[i][j][k]=0;for(i=0;i<12;i++)for(wd=0,d
6、ay=1;day<=day_tbl[leap][i];day++){date[i][wd][sw]=day;sw=++sw%7;if(sw==0)wd++;}fprintf(fp,"当年日历:");fprintf(fp,"*TheCalendarofYear%d*",b[0]);//输出当年日历的表头printf("当年日历:");printf("*TheCalendarofYear%d*",b[0]);for(i=0;i<6;i++){for(wd=0,k=0;k<7;k++)wd+=date[i][5][k]+date[i+6][5][k
7、];wd=wd?6:5;fprintf(fp,"");//用switch语句将数字转化为英文switch(i+1){case1:fprintf(fp,"January");break;case2:fprintf(fp,"Februry");break;case3:fprintf(fp,"March");break;case4:fprintf(fp,"April");break;case5:fprintf(fp,"May");break;case6:fprintf(fp,"June");break;case7:fprintf(fp,"July");break;ca
8、se8:fprintf(fp,"August");break;case9:fprintf(fp,"September");break;case10:fprintf(fp,"October");break;case11:fprintf(fp,"November");break;case12:fprintf(fp,"December");break;}fprintf(fp,"");switch(i+7){case1:fprintf(fp,"January");break;case2:fprintf(fp,"Februry");break;case3:fprintf(fp
9、,"March");break;case4:fprintf(fp,"April");break;case5:fprintf(fp,"May");break;case6:fprintf(fp,"June");break;case7:fprintf(fp,"July");break;case8:fprintf(fp,"August");break;case9:fprintf(fp,"September");break;case10:fprintf(fp,"October");break;case11:fprintf(fp,"November");break;case