#include <iostream>
/*输入年月 输出这个月的天数
注意闰年2月有29天*/
using namespace std;
bool leap_year(int n); //是否闰年判断
int main(){
int month,year=0;
int determine =0;
cin>>year>>month;
determine=leap_year(year);
if(month<=12&&month>0){
switch(month){
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12: cout<<"31";
break;
case 4:
case 6:
case 9:
case 11: cout<<"30";
break;
case 2:{ if(determine==true){
cout<<"29";
break;
}
else cout<<"28";
break;
}
}
}
return 0;
}
bool leap_year(int n){
if(n%100==0&&n%400==0){
return true;
}
else if(n%4==0 ){
return true;
}
else return false;
}
输入年月输出这个月的天数
最新推荐文章于 2024-04-15 17:07:27 发布