#include<stdio.h>
void week_several(void);
void dates(void);
void Is_leapyear(int year);
main()
{ int num;
printf(" MENU");
printf("1.Inquires some year, month and day is the week several\n");
printf("2.Inquires some year whether is the leap year\n");
printf("3.Prints some year the whole year calendar\n");
printf("4.Exit\n");
printf("Please choose a number:");
scanf("%d",&num);
switch(num)
{case 1: dates();break;
case 2: break;
case 3:
case 4: break;
default: printf("Your input is not correct, please choose again");
}
/*主函数*/
void dates(void)
{int year,month,day,week_several;
printf("Please give the date you want to inquire");
scanf("%d%d%d",&year,&month,&day);
prinf("the date you inquire is:%s",week_several(year,month,day));
}
/*查询星期几的主函数*/
void week_several(long year,long month,long day)
{int i,j,k,week_day,days=0;
for(i=1900;i<year;i++)
{if(Is_leapyear(i)) days+=366;
else days+=365;
}
/*计算年份天数*/
for(j=1;j<month;j++)
{switch(j)
{case 2:if(Is_leapyear(year)) days+=29;
else days+=28; break;
case 4: case 6: case 9: case 11: days+=30; break;
default: days+=31; break;
}
}
/*计算月份天数*/
for(k=1;k<=day;k++)
days++;
/*计算总天数 */
week_day=days%7;
switch(week_day)
{case 1: return("Monday"); break;
case 2: return("Tuesday"); break;
case 3: return("Wednesday"); break;
case 4: return("Thusday"); break;
case 5: return("Friday"); break;
case 6: return("Saturday"); break;
case 0: return("Sunday"); break;
}
}
void Is_leapyear(int year) /*判断闰年*/
{return(year%4==0&&year%100!=0||year%400==0)}
程序没写完 但
里面两个报错 :
void dates(void)报错 expression syntax in function
最后一行报错 少了个}
帮忙哦