题解 | #获得月份天数#
获得月份天数
https://www.nowcoder.com/practice/13aeae34f8ed4697960f7cfc80f9f7f6
#include<stdio.h>
int isprime(int year)
{
if(year%4==0&&year%100!=0||year%400==0)
return 1;
else
return 0;;
}
int days(int year, int month)
{
int arr[12]={31,28,31,30,31,30,31,31,30,31,30,31};
if(isprime(year))
arr[1]=29;
return arr[month-1];
}
int main()
{
int year=0;
int month=0;
while( scanf("%d%d",&year,&month)!=EOF)
{
printf("%d\n",days(year,month));
}
return 0;
}
