程序如下:
#include
#define LEAP_YEAR(year, month)\
do{\
if((year % 400 == 0) || (year % 4 == 0 && year % 100 != 0))\
{\
printf("%d is Leap!\n", year);\
}\
else\
{\
printf("%d is not Leap!\n", year);\
}\
switch(month)\
{\
case 1:\
case 3:\
case 5:\
case 7:\
case 8:\
case 10:\
case 12:\
printf("month %d is 31 days\n", month);\
break;\
case 4:\
case 6:\
case 9:\
case 11:\
printf("month %d is 30 days\n", month);\
break;\
case 2:\
if(year % 400 == 0 || (year % 4 == 0 && year % 100 != 0))\
printf("month %d is 29 days\n", month);\
else\
printf("month %d is 28 days\n", month);\
break;\
default:\
printf("The input month is wrong!\n");\
break;\
}\
}while(0)
int main(void)
{
int year, month;
printf("Input the year:");
scanf("%d", &year);
printf("Input the month:");
scanf("%d", &month);
LEAP_YEAR(year, month);
return 0;
}