根据月份运算天数

来源:互联网 发布:sai mac 打不开 编辑:程序博客网 时间:2024/05/15 19:20
#include <stdio.h>#include <stdlib.h>#define MONTHS 12int main(){    int days[MONTHS]={31,28,31,30,31,30,31,31,39,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;}

运算结果如下

原创粉丝点击