const int month[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};//每月天数
int is_leap(int year) //是否闰年
{
if(year % 4 == 0 && year % 100 || year % 400 == 0) return 1;
else return 0;
}
int get_days(int y,int m)//某年某月多少天
{
if(m == 2) return month[m] + is_leap(y);
return month[m];
}
日期问题常用函数和数组
最新推荐文章于 2024-07-24 22:13:06 发布