/**
* Desc: 输入年月求月份天数
* Authors: hao.l
* Date: 2016/10/17
* Modify by:
*
*/
#include <iostream>
#include <string>
using namespace std;
int getDays(int,int);
int main(){
cout<<getDays(2016,10)<<endl;
return 0;
}
int getDays(int year,int month){
switch(month){
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
return 31;
case 4:
case 6:
case 9:
case 11:
return 30;
case 2:
// 能被4整除同时不能被100整除的或者被400整除的为闰年
if(year%4==0 && year%100!=0 || year%400==0){
return 29;
}
return 28;
}
}
闰年判断
最新推荐文章于 2022-07-25 16:04:03 发布