问答详情
源自:4-17 switch与if语句的应用

请大家帮忙找错误

  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;

   

    }


提问者:yuyuyuaaa 2015-11-25 21:40

个回答

  • DoDream
    2015-11-26 09:49:11
    已采纳

    一月和二月不管是不是闰年都不应该加1.