为什么这样算多了一天?
#include <stdio.h>
int main()
{
/* 定义需要计算的日期 */
int year = 2008;
int month = 8;
int day = 8;
int sum;
switch(month)
{case 1:
case 2:sum=sum+1;break;
case 3:
case 4:sum=sum+2;break;
case 5:
case 6:sum=sum+3;break;
case 7:
case 8:sum=sum+4;break;
case 9:sum=sum+5; break;
case 10:
case 11:sum=sum+6;break;
case 12: break;
}
if(year%400==0)
sum=sum+1;
else
sum=sum+30*(month-1)+day-2;
printf("%d",sum);
return 0;
}