#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int run_year(int y)
{
if (y % 100 != 0 && y % 4 == 0 || y % 400 == 0)
{
return 1;
}
else
return 0;
}//判断y是不是闰年;如果是,返回1
int getdays_ofmonth(int y, int m)
{
int arr[] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
int d = arr[m];
int r = run_year(y);
if (r == 1 && m == 2)
{
d += 1;
}
return d;
}//获取某月的天数
int main()
{
int m = 0;
int y = 0;
scanf("%d%d", &y, & m);
int r=getdays_ofmonth(y, m);
printf("%d ", r);
return 0;
}
标签:输出,arr,年份,return,int,天数,31,30,ofmonth
From: https://blog.51cto.com/u_16261646/7571819