C++程序设计:求某一年某一月份的天数
【问题描述】
输入年月,求该月份的天数。
【样例输入】
2000 2
【样例输出】
29
#include <iostream>
using namespace std;
int main() {
int year,month;
cin>>year>>month;
if(year%4==0&&year%100!=0||year%400==0) {
if (month==1||month==3||month==5||month==7||month==8||month==10||month==12) {
cout<<"31";
}
if (month==4||month==6||month==9||month==11) {
cout<<"30";
}
if (month==2) {
cout<<"29";
}
}
if(year%100==0&&year%400!=0||year%4!=0) {
if (month==1||month==3||month==5||month==7||month==8||month==10||month==12) {
cout<<"31";
}
if (month==4||month==6||month==9||month==11) {
cout<<"30";
}
if (month==2) {
cout<<"28";
}
}
return 0;
}