为什么输出的全是0天啊

img

img


刚学c没多久,一直在调整了为啥还是不行,希望能够得到指点,谢谢辽

代码写的有问题,break都没有
请看一下代码,有帮助的话采纳一下哦!

#include <stdio.h>
int main() {
    int year,month;
    scanf("%d %d",&year,&month);
    printf("Please enter year and month ");
    if((year%4==0 && year%100!=0 ) || year%400==0 ){     //判断是否是闰年
        switch (month) {
              case 2: 29;
                printf("There are 29 days in this month");
                break;
              case 1:
              case 3:
              case 5:
              case 7:
              case 8:
              case 10:
              case 12:
                  printf("There are 31 days in this month");
                break;
              case 4:
              case 6:
              case 9:
              case 11:
                  printf("There are 30 days in this month");
                break;
        }
    } else{
        switch (month) {
            case 2: 28;
                printf("There are 28 days in this month");
                break;
            case 1:
            case 3:
            case 5:
            case 7:
            case 8:
            case 10:
            case 12:
                printf("There are 31 days in this month");
                break;
            case 4:
            case 6:
            case 9:
            case 11:
                printf("There are 30 days in this month");
                break;
        }
    }
 
    return 0;
}

你要明白,在switch   case语句中,
在case语句后面如果没有break,
它就会顺序执行下去,有了break才
会执行相对应的位置然后退出。