直接套y总的模板即可
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
int days[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
int leap(int year)
{
if(year % 4 == 0 && year % 100 != 0 || year % 400 == 0) return 1;
return 0;
}
bool check(int year,int month,int day)
{
if(month <= 0 || month > 12) return false;
if(day == 0 || month != 2 && day > days[month]) return false;
if(month == 2)
{
int x = leap(year);
if(day > days[2] + x) return false;
}
return true;
}
int main()
{
int a,b,c;
scanf("%d/%d/%d",&a,&b,&c);
for(int i = 19600101;i <= 20591231;i++)
{
int year = i / 10000;
int month = i % 10000 / 100;
int day = i % 100;
if(check(year,month,day))
{
if(a == year % 100 && b == month && c == day
|| a == month && b == day && c == year % 100
|| a == day && b == month && c == year % 100)
{
printf("%d-%02d-%02d\n",year,month,day);
}
}
}
return 0;
}