瞧一瞧看一看
#include <stdio.h>
int main()
{
int year = 2008;
int month = 8;
int day = 8;
int sum,exmonth;
sum=day;
for(exmonth=1;exmonth<month;exmonth++)
{
switch(exmonth)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
sum+=31;
break;
case 4:
case 6:
case 9:
case 11:
sum+=30;
break;
case 2:
if(year%4==0)
{
sum+=29;
}
else
{
sum+=28;
}
break;
}
}
printf("%d年%d月%d日是该年的第%d天",year,month,day,sum);
return 0;
}
感觉我这个比较简单