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(!day || month < 0 || month > 12 ) return false;
if(month != 2 && day >months[month]) return false;
if(month == 2)
{
if((year%4==0&&year%100!=0)||(year%400==0)) //闰年特判
{
if(day > 29) return false;
}
else
{
if(day > 28) return false;
}
}
return true;
}