定义描述一年12个月的枚举类型,并定义函数根据月份输出本月天数

2020-06-19 教育 98阅读
typedef enum {Jan=1,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec} MONTH ;
char daysOfMonth(MONTH month)
{
const static char DaysOfMonth[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
if(month >= Jan && month <= Dec)
printf("There're %d days in month %d\n",DaysOfMonth[month-1], month);
else
printf("month should be from %d to %d\n",Jan,Dec);
}
声明:你问我答网所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系fangmu6661024@163.com