新手求解枚举问题,年份输入打出月份,请高手大神教教我,谢谢
定义一个枚举类型enum month描述1至12个月各用英文缩写表示,并且编写一个程序,使得输入一个年份,将这个年份的每个月的英文名全称以及月数输出。我觉得这道题第一必须解决闰年平年问题,我使用了if else
可是枚举的Jan等月数,英文名怎么输出,实在不会。请各位高手帮忙
#include<stdio.h>
enum month { Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec };
int main()
{ int year;
char *monthDetail1[]={"January 31","February 28","March 31","April 30","May 31","June 30","July 31","August 31","September 30","October 31","Novmber 30","Decmber 31"};
char *monthDetail2[]={"January 31","February 27","March 31","April 30","May 31","June 30","July 31","August 31","September 30","October 31","Novmber 30","Decmber 31"};
scanf("%d",year);
if(!(year%4)&&year%100||!(year%400))
printf("%s\n",monthDetail2);
else
printf("%s\n",monthDetail1);
return 0;
}