主题:[讨论]求教
#include<stdio.h>
int main()
{
int year,month,day;
scanf("%d%d",&year,&month);
if((year%400==0) ||( (year%100!=0) && (year%4==0)))
{
switch(month)
{ case 1: day=31;break;
case 2: day=28;break;
case 3: day=31;break;
case 4: day=30;break;
case 5: day=31;break;
case 6: day=30;break;
case 7: day=31;break;
case 8: day=31;break;
case 9: day=30;break;
case 10: day=31;break;
case 11: day=30;break;
case 12: day=31;break; }
}
else if
{
switch(month)
{ case 1: day=31;break;
case 2: day=29;break;
case 3: day=31;break;
case 4: day=30;break;
case 5: day=31;break;
case 6: day=30;break;
case 7: day=31;break;
case 8: day=31;break;
case 9: day=30;break;
case 10: day=31;break;
case 11: day=30;break;
case 12: day=31;break; }
}
printf("&d-%d-%d\n",year-month-day);
return 0;
}
出现一堆,错误,小弟,不知道如何修改。
int main()
{
int year,month,day;
scanf("%d%d",&year,&month);
if((year%400==0) ||( (year%100!=0) && (year%4==0)))
{
switch(month)
{ case 1: day=31;break;
case 2: day=28;break;
case 3: day=31;break;
case 4: day=30;break;
case 5: day=31;break;
case 6: day=30;break;
case 7: day=31;break;
case 8: day=31;break;
case 9: day=30;break;
case 10: day=31;break;
case 11: day=30;break;
case 12: day=31;break; }
}
else if
{
switch(month)
{ case 1: day=31;break;
case 2: day=29;break;
case 3: day=31;break;
case 4: day=30;break;
case 5: day=31;break;
case 6: day=30;break;
case 7: day=31;break;
case 8: day=31;break;
case 9: day=30;break;
case 10: day=31;break;
case 11: day=30;break;
case 12: day=31;break; }
}
printf("&d-%d-%d\n",year-month-day);
return 0;
}
出现一堆,错误,小弟,不知道如何修改。