猿问

我 这段代码怎么错了(百度了一下说我有中文乱码?我没找到啊...)

#include <stdio.h>

int main() 

    /* 定义需要计算的日期 */

    int year = 2008;

    int month = 8;

    int day = 8;

    int sum ;

    switch (month)

    {

    if (year%100==0&&year%400==0||year%4==0&&year%100!=0)

    { 

        case 1 : sum = 0  + day ;

        printf("%d年%d月%d日是第%d天",year,month,day,sum);break;

        case 2 : sum = 31 + day ; 

        printf("%d年%d月%d日是第%d天",year,month,day,sum);break;

        case 3 : sum = 31 + 29 + day ; 

        printf("%d年%d月%d日是第%d天",year,month,day,sum);break;

        case 4 : sum = 31 + 29 + 31 + day ;

        printf("%d年%d月%d日是第%d天",year,month,day,sum);break;

        case 5 : sum = 31 + 29 + 31 + 30 day ;

        printf("%d年%d月%d日是第%d天",year,month,day,sum);break;

        case 6 : sum = 31 + 29 + 31 + 30 + 31 +day ; 

        printf("%d年%d月%d日是第%d天",year,month,day,sum);break;

        case 7 : sum = 31 + 29 + 31 + 30 + 31 + 30  day ;

        printf("%d年%d月%d日是第%d天",year,month,day,sum);break;

        case 8 : sum = 31 + 29 + 31 + 30 + 31 + 30 + 31 + day ; 

        printf("%d年%d月%d日是第%d天",year,month,day,sum);break;

        case 9 : sum = 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31  + day ;

        printf("%d年%d月%d日是第%d天",year,month,day,sum);break;

        case 10: sum = 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31  + 30 + day ; 

        printf("%d年%d月%d日是第%d天",year,month,day,sum);break;

        case 11: sum = 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31  + 30 + 31 + day ; 

        printf("%d年%d月%d日是第%d天",year,month,day,sum);break;

        case 12: sum = 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31  + 30 + 31 + 31 + day ; 

        printf("%d年%d月%d日是第%d天",year,month,day,sum);break;

        

        

    }

    

    else 

    {

        case 1 : sum = 0  + day ;

        printf("%d年%d月%d日是第%d天",year,month,day,sum);break;

        case 2 : sum = 31 + day ; 

        printf("%d年%d月%d日是第%d天",year,month,day,sum);break;

        case 3 : sum = 31 + 28 + day ;

        printf("%d年%d月%d日是第%d天",year,month,day,sum);break;

        case 4 : sum = 31 + 28 + 31 + day ;

        printf("%d年%d月%d日是第%d天",year,month,day,sum);break;

        case 5 : sum = 31 + 28 + 31 + 30 day ; 

        printf("%d年%d月%d日是第%d天",year,month,day,sum);break;

        case 6 : sum = 31 + 28 + 31 + 30 + 31 +day ; 

        printf("%d年%d月%d日是第%d天",year,month,day,sum);break;

        case 7 : sum = 31 + 28 + 31 + 30 + 31 + 30  day ;

        printf("%d年%d月%d日是第%d天",year,month,day,sum);break;

        case 8 : sum = 31 + 28 + 31 + 30 + 31 + 30 + 31 + day ; 

        printf("%d年%d月%d日是第%d天",year,month,day,sum);break;

        case 9 : sum = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31  + day ; 

        printf("%d年%d月%d日是第%d天",year,month,day,sum);break;

        case 10: sum = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31  + 30 + day ;

        printf("%d年%d月%d日是第%d天",year,month,day,sum);break;

        case 11: sum = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31  + 30 + 31 + day ;

        printf("%d年%d月%d日是第%d天",year,month,day,sum);break;

        case 12: sum = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31  + 30 + 31 + 31 + day ; 

        printf("%d年%d月%d日是第%d天",year,month,day,sum);break;

           

    }

        }









return 0;

}


橙了个棒棒糖
浏览 1482回答 1
1回答

慕丝2543519

有几行day前面没加号
随时随地看视频慕课网APP
我要回答