#include <stdio.h>
#include <stdlib.h>
int Mdays(int year,int month,int day); /*用户输入的那年的天数*/
int Year (void); /*判断年份的合法性*/
int Month (void); /*判断月份的合法性*/
int Day (int year,int month); /*判断天数的合法性*/
int Days (int year,int month,int day); /*总天数*/
void Prin(int z,int year,int month); /*打印某月日历*/
main()
{
do{
int a,year,month,day,z;
printf("\t \n ------主菜单------\n");
printf("\t 1.查询闰年和平年\n");
printf("\t 2.打印某月的日历\n");
printf("\t 3.打印某年的日历\n");
printf("\t 4.查询某年某月某日为星期几\n");
printf("\t 0.退出程序\n");
printf("请输入任务的序号:");
scanf("%d",&a);
switch (a)
{
case 1:
year=Year();
if ((year%4==0 && year%100!=0) || (year%400==0))
printf("%d年为闰年。\n",year);
else printf("%d年为平年。\n",year);
break;
case 2:
year=Year();
month=Month();
day=1;
z=Days(year,month,day);
Prin(z,year,month);
break;
case 3:
year=Year();
for(month=1;month<=12;month++)
{
day=1;
z=Days(year,month,day);
Prin(z,year,month);
}
break;
case 4:
year=Year();
month=Month();
day=Day(year,month);
z=Days(year,month,day)%7;
switch (z)
{
case 1:
printf ("%d年%d月%d日为星期日\n",year,month,day);
break;
case 2:
printf ("%d年%d月%d日为星期一\n",year,month,day);
break;
case 3:
printf ("%d年%d月%d日为星期二\n",year,month,day);
break;