#include<stdio.h>
#include<stdbool.h>
bool lspyear(int year)
{
if (year % 4 == 0 && year & 100 != 0 || year % 400 == 0)
return 1;
else
return 0;
}
int main()
{
int year, month,day;
printf("请输入月份天数:\n");
scanf("%d%d", &year, &month);
switch(month)
{
case(1):
case(3):
case(5):
case(7):
case(8):
case(10):
case(12):
day = 31;
break;
case(4):
case(6):
case(9):
case(11):
day = 30;
break;
case(2):
if (lspyear(year))
{
day = 29;
}
else
{
day = 28;
}
default:
break;
}
printf("%d", day);
return 0;
}
C/C++蓝桥杯之月份天数的问题
最新推荐文章于 2024-08-23 16:28:38 发布