猿问

输出结果不对,求大神看看哪里错了

#include<stdio.h>
#define MONTH 12
int main()
{
 int days[MONTH]={31,28,31,30,31,30,31,31,30,31,30,31};
 int month;
 do{
   printf("input a month:");
   scanf("%d",&month);
 }while (month<1||month>12);
 printf("The number of days is %d\n",days[MONTH-1]);
    return 0;
}


结果的2月不对  为什么呢

慕九州6240490
浏览 1644回答 3
3回答

qq_青枣工作室_0

printf("The number of days is %d\n",days[MONTH-1]);改为printf("The number of days is %d\n",days[month-1]);  // 小写的month

惊回头

视觉冲击

Amos_落叶

现在输出的是12月的天数,,days[MONTH-1])改成小写就OK了!
随时随地看视频慕课网APP
我要回答