这个的问题出在哪里,感谢指正。_
这个的问题出在哪里,感谢指正。_
这个的问题出在哪里,感谢指正。_
#include <stdio.h>
int main()
{
int year = 2008;
int day,month,sum;
sum=0;
for(month=1;month<=7;month=month+1)
{
switch(month)
{ case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
day=31;
sum+=day;
continue;
case 4:
case 6:
case 9:
case 11:
day=30;
sum+=day;
continue;
case 2:
day=29;
sum+=day;
continue;
default:
break;
}
}
sum+=8;
printf("%d年%d月%d日是该年的第%d天",year,month,day,sum);
return 0;
}
哥。。Switch里case是代表要输出的内容
#include <stdio.h>
int main()
{
int year=2008;
int day,month0,month,sum;
sum=0;
for(month0=8,month=1;month<month0;month++)
{
switch(month)
{ case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
day=31;
sum+=day;
continue;
case 4:
case 6:
case 9:
case 11:
day=30;
sum+=day;
continue;
case 2:
if(year%4==0&&year%100!=0||year%400==0)
{
day=29;
}
else
{
day=28;
}
sum+=day;
continue;
default:
break;
}
}
day=8;
sum+=8;
printf("%d年%d月%d日是该年的第%d天",year,month,day,sum);
return 0;
}
原来我前面弄错了,这个应该是可以的了。