1526:这个月有多少天
Description
输入年月,判断这年的 这个月有多少天?
注意闰年。
Input
年月 y m。
Output
天数
d
Sample Input
2015 2
Sample Output
28
#include<iostream>
using namespace std;
int main()
{
int y,m;
cin>>y>>m;
if(y%4==0&&y%100!=0||y%400==0)
{
if(m==1||m==3||m==5||m==7||m==8||m==10||m==12)
{
cout<<"31";
return 0;
}
if(m==2)
cout<<"29";
else
cout<<"30";
}
else
{
if(m==1||m==3||m==5||m==7||m==8||m==10||m==12)
{
cout<<"31";
return 0;
}
if(m==2)
cout<<"28";
else
cout<<"30";
}
return 0;
}