为什么要int i 和switch(i)?如果switch(month)要怎么改?
#include <stdio.h>
int main()
{
int year = 2008;
int month = 8;
int day = 8;
int j=0;
int i;
for(i=1;i<month;i++)
{
switch(i)
{
case 1:
j += 31;
break;
case 2:
if(year%400==0||year%4==0&&year%100!=0)
{
j+= 29;
}
else
{
j += 28;
}
break;
case 3:
j += 31;
break;
case 4:
j += 30;
break;
case 5:
j += 31;
break;
case 6:
j += 30;
break;
case 7:
j+= 31;
break;
case 8:
j+= 31;
break;
case 9:
j += 30;
break;
case 10:
j += 31;
break;
case 11:
j += 30;
break;
case 12:
j += 31;
break;
}
}
j += day;
printf("%d年%d月%d日是该年的第%d天",year,month,day,j);
return 0;
}