}
return 0;
void hy()//欢迎信息 { }
void Time() //获取系统时间 { }
int whichWeekday(int year, int month, int day)//判断某天为星期几 { }
void yearMonth(int year, int month)//打印某年某月的月历 {
int i,j=0;
int weekday; //计算这个月第一天是星期几 weekday = whichWeekday(year, month, 1); int weekday;
if (month == 1 || month == 2)//公式中要把月和月换成是上一年的月和月 { }
weekday=(day+2*month+3*(month+1)/5+year+year/4-year/100+year/400)%7; //计算星期的公式 return weekday+1;
month += 12; year -= 1;
time_t t; struct tm *tp;
static char *week[]={\一\二\三\四\五\六\日\t=time(NULL); tp=localtime(&t);
printf(\ ─────────────────────\\n\
printf(\系统时间日期:%d年%d月%d日\printf(\printf(\星期%s\\n\
printf(\ ─────────────────────\\n\
printf(\
欢迎使用万年历查询系统\\n\\n\
Sleep(700);//延时毫秒 printf(\
祝您每天好心情!\\n\\n\\n\
Sleep(1000);
printf(\版本:v2.0\\n\\n\\n\Sleep(1000);
printf(\正在进入功能菜单,请稍候》》\\n\Sleep(5000);//延时秒
}
printf(\ printf(\printf(\
%d年%d月\\n\
------------------------------------------------\\n\ 星期一星期二星期三星期四星期五星期六星期天\\n\
if(isLeapYear(year) && month == 2)
days[1] = days[1] + 1;
\
printf(\
for(i = 1; i < weekday; i ++)
printf(\
for(i = 0; i < 8 - weekday; i ++) { }
printf(\
\
printf(\printf(\
for(i = 9-weekday; i <= days[month-1]; i ++,j++) { }
printf(\
------------------------------------------------\\n\
if(j == 7) { }
printf(\
j = 0; printf(\
\
void monthDay(int year)//输入年份,打出个月历 { }
void menu()//主菜单 {
printf(\
-----------------------------------------------\\n\
int i;
for(i = 0; i < 12; i ++)
yearMonth(year,i+1);
printf(\
printf(\printf(\万年历查询系统\\n\\n\printf(\printf(\printf(\printf(\printf(\
**************************************************\\n\ ** 1、输入年份,判断是否为闰年 **\\n\ ** 2、输入年月日,判断该日为星期几 **\\n\ ** 3、输入年份,打出个月历 **\\n\ ** 4、输入月份,打出该月的日历 **\\n\
}
printf(\printf(\
** 5、退出 **\\n\ **************************************************\\n\\n\
void main()//主函数 {
int num,year,month,day,weekday; char ch; while(1) {
system(\hy();//欢迎信息
tz:system(\语句跳转菜单标志 Time();//调用系统函数 menu();//菜单 printf(\
请输入对应操作:\//清屏
scanf(\switch(num) {
case 1: {
system(\t1:printf(\
请输入年份,确定按‘回车’(格式:):\\n\语句标志
scanf(\if(year>=3000||year<=1600) { }
if(isLeapYear(year)) else
printf(\提示:\\n如继续运行请按\\n如回首菜单请按\\n如退出请按\\n请选择:\
printf(\
%d年不是闰年。\\n\
printf(\
%d年是闰年。\\n\
system(\
printf(\输入错误,系统及即将返回!\Sleep(3000); goto tz;
ch=getch(); if(ch=='1')
goto t1;//goto语句返回的t1
if(ch=='2')
goto tz;//执行主函数
if(ch=='0')
exit(0);//退出
}
break;
case 2: {
system(\t2:printf(\
请输入年月日,以空格隔开,确定按‘回车’(格式:6 10):\\n\
scanf(\
if((year>=3000||year<=1600)||(month>=12||month<0)||(day>=31||day<=0)) { }
weekday = whichWeekday(year, month, day); printf(\
这天是星期%d。\\n\\n\
system(\
printf(\输入错误,系统及即将返回!\Sleep(3000); goto tz;
printf(\提示:\\n如继续运行请按\\n如回首菜单请按\\n如退出请按\\n请选择:\
ch=getch(); if(ch=='1')
goto t2;
if(ch=='2')
} case 3: {
system(\t3:printf(\
请输入年份,确定按‘回车’(格式:):\\n\
goto tz;
if(ch=='0')
exit(0);
break;
scanf(\if(year>=3000||year<=1600) { }
monthDay(year);
printf(\提示:\\n如继续运行请按\\n如回首菜单请按\\n如退出请按\\n请选择:\
system(\
printf(\输入错误,系统及即将返回!\Sleep(3000); goto tz;
ch=getch(); if(ch=='1')
goto t3;
if(ch=='2')
}
goto tz;
if(ch=='0')
exit(0);
break;
case 4:
{ { } }
yearMonth(year,month);
if(isLeapYear(year) && month == 2)//如果年份为闰年,则月加天
days[1] = days[1] + 1;
system(\
printf(\输入错误,系统及即将返回!\Sleep(3000); goto tz; system(\t4:printf(\
请输入年份(格式:):\\n\
scanf(\printf(\
请输入月份,确定按‘回车’(格式:):\\n\
scanf(\
if((year>=3000||year<=1600)||(month>=12||month<0))
printf(\提示:\\n如继续运行请按\\n如回首菜单请按\\n如退出请按\\n请选择:\ch=getch(); if(ch=='1') goto t4; if(ch=='2')
goto tz;
if(ch=='0')
exit(0);
break;
case 5:
{
printf(\ printf(\ch=getch(); if(ch == '2') else { }
printf(\
\
goto tz;
是否确定退出?\\n\确定请按,取消请按\
exit(0);//退出