2002-03-04 2004-02-03 2004-03-02
#include <iostream>
using namespace std;
int days[13]={0,31,30,31,30,31,30,31,31,30,31,30,31};
bool check_valid(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 leap=year%100!=0 &&year%4==0 ||year%400==0;
if(day>days[2]+leap)
return false;
}
}
return true;
}
int main(int argc, char** argv) {
int a,b,c;
scanf("%a/%b/%c",&a,&b,&c);
for(int i=19600101;i<=20251231;i++){
int year=i/1000, month=i/100%100, day=i%100; //分别取年月日
if(check_valid(year,month,day)){ //自定义方法,检查是否满足条件。
if(year%100==a && month==b &&day==c ||month==a &&day==b &&year%100==c ||day==a &&month==b &&year%100==c){ //重点
printf("%d-%02d-%02d\n",year,month,day);
}
}
}
return 0;
}