codeup2661 计算某月天数
时空限制 1000ms/128MB
题目描述
输入一个年份和月份,请输出这个月的天数。
输入
两个整数,表示年份和月份,用一个空格隔开
输出
一行,就一个整数,表示这个月的天数
样例输入
1998 5
样例输出
31
代码
#include<iostream>
using namespace std;
int main(){
int y,m;
cin>>y>>m;
switch (m){
case 1: case 3: case 5: case 7: case 8: case 10:
case 12: cout<<31<<endl; break;
case 4: case 6: case 9:
case 11: cout<<30<<endl; break;
case 2: if (y%4==0&&y%100!=0 || y%400==0) cout<<29<<endl;
else cout<<28<<endl;
}
return 0;
}