《电气实训报告 万年历》由会员分享,可在线阅读,更多相关《电气实训报告 万年历(3页珍藏版)》请在金锄头文库上搜索。
1、#include #include char MonthDay1=31,28,31,30,31,30,31,31,30,31,30,31; char MonthDay2=31,29,31,30,31,30,31,31,30,31,30,31; char *WeekDayName=“日“,“一“,“二“,“三“,“四“,“五“,“六“; char runnian(int y) char a; a=(y%4 = 0 return a; int xingqi(int y,int m, int d) int week;if(m=1) m=13;if(m=2) m=14;week=(d+2*m+3*(m
2、+1)/5+y+y/4-y/100+y/400)%7; return week; char cxxq() char c;int y,m,d,t,week;do system(“cls“); printf(“请输入年月日(* * *)n“);scanf(“%d %d %d“, if (runnian(y)=1) t=MonthDay2(m-1)%12;else t=MonthDay1(m-1)%12; if(d=t) week=xingqi(y,m,d);printf(“%d 年%d 月%d 日是星期%s,是否继续查询(Y/N)? “,y,m,d,WeekDayNameweek);scanf(“
3、%s“, else printf(“日期错误!n 是否继续查询(Y/N)?“);scanf(“%s“,while (c=Y | c=y);return c; void month(int y,int m) int d,t,week;week=xingqi(y,m,1);if (runnian(y)=1) t=MonthDay2(m-1)%12;else t=MonthDay1(m-1)%12; for (d=0;d7;d+) printf(“t%s“,WeekDayNamed); printf(“n“); for (d=1;d=t;d+) printf(“t%d“,d);if (xingqi(
4、y,m,d)=6) printf(“n“); printf(“n“); char xsyf() char c;int y,m; do system(“cls“); printf(“请输入年月(* *)n“); scanf(“%d %d“, printf(“ttt%d 年t%d 月nn“,y,m);month(y,m);printf(“是否继续打印(Y/N)?“);scanf(“%s“, while (c=Y | c=y);return 0; char year() char c;int y,m;do system(“cls“); printf(“请输入年份(*)n“);scanf(“%d“,p
5、rintf(“ttt%d 年年历n“,y); for (m=1;m=12;m+) printf(“ttt%d 月n“,m);month(y,m); printf(“n 是否继续打印(Y/N)?“);scanf(“%s“, while (c=Y | c=y);return 0; main() char doexit=0,xuanzhe; do system(“cls“); printf(“显示某年日历-1n“);printf(“显示某月日历-2n“);printf(“查找星期几-3n“);printf(“退出-4n“);printf(“请选择(1-4):“);scanf(“%s“,switch (xuanzhe) case 1:year();break;case 2:xsyf();break;case 3:cxxq();break;case 4:exit(0);break; while(doexit=0);