switch(month)
{
case 1:sum=0;break;
case 2:sum=31;break;
case 3:sum=28+31;break;
case 4:sum=31+28+31;break;
case 5:sum=30+28+31+31;break;
case 6:sum=31+30+28+31+31;break;
case 7:sum=30+31+30+28+31+31;break;
case 8:sum=31+30+31+30+28+31+31;break;
case 9:sum=31+31+30+31+30+28+31+31;break;
case 10:sum=30+31+31+30+31+30+28+31+31;break;
case 11:sum=31+30+31+31+30+31+30+28+31+31;break;
case 12:sum=30+31+30+31+31+30+31+30+28+31+31;break;
}
if(year%4==0&&year%100!=0||year%400==0)
{
sum=sum+1+day;
}
else{
sum=sum+day;
}
一月和二月不管是不是闰年都不应该加1.