int plugclass::Leapyear(int year, int month)
{
int flag = 0;
int strmonth;
if(year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
flag=1; //是闰年
switch(month)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
strmonth = 31;
break;
case 2:
if(flag==1)
strmonth = 29;
else
strmonth = 28;
break;
case 4:
case 6:
case 9:
case 11:
strmonth = 30;
break;
default:
break;
}
return strmonth;
}
调用方法
Leapyear(2014,4);
结果:30