#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
int months[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
//判断是不是日期
bool check(int date)
{
int year = date / 10000;
int month = date % 10000 / 100;
int day = date % 100;
if(!month || month > 13 || !day) return false;
if(month != 2 && day > months[month]) return false;
if(month == 2)
{
bool leap = year % 4 == 0 && year % 100 || year %400 == 0;
if(day > months[2] + leap) return false;
}
return true;
}
模板——判断一个8位数是不是日期
最新推荐文章于 2022-11-17 09:28:34 发布