#include<stdio.h>#define MONTH 12int 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月不对 为什么呢
3 回答
已采纳
qq_青枣工作室_0
TA贡献446条经验 获得超754个赞
printf("The number of days is %d\n",days[MONTH-1]);
改为
printf("The number of days is %d\n",days[month-1]); // 小写的month
- 3 回答
- 0 关注
- 1643 浏览
添加回答
举报
0/150
提交
取消