#include<stdio.h>
int main()
{
int year,month;
printf("請輸入一個年份和月份:");
scanf("%d%d",&year,&month);
if((year % 4 == 0 && year % 100 !=0)||(year % 400 ==0))
{
switch(month)
{
case 1:printf("該月有31天。");break;
case 2:printf("該月有29天。");break;
case 3:printf("該月有31天。");break;
case 4:printf("該月有30天。");break;
case 5:printf("該月有31天。");break;
case 6:printf("該月有31天。");break;
case 7:printf("該月有31天。");break;
case 8:printf("該月有31天。");break;
case 9:printf("該月有30天。");break;
case 10:printf("該月有31天。");break;
case 11:printf("該月有30天。");break;
case 12:printf("該月有31天。");break;
default:printf("error!");
}
}
else
{
switch(month)
{
case 1:printf("該月有31天。");break;
case 2:printf("該月有28天。");break;
case 3:printf("該月有31天。");break;
case 4:printf("該月有30天。");break;
case 5:printf("該月有31天。");break;
case 6:printf("該月有31天。");break;
case 7:printf("該月有31天。");break;
case 8:printf("該月有31天。");break;
case 9:printf("該月有30天。");break;
case 10:printf("該月有31天。");break;
case 11:printf("該月有30天。");break;
case 12:printf("該月有31天。");break;
default:printf("error!");
}
}
return 0;
}