题目描述
样例
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<set>
using namespace std;
int days[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
bool isright(int year,int month,int day){
if(year<1960||year>2059) return false;
if(month<1||month>12) return false;
if(day<1||day>days[month]) return false;
if(month==2){
int flag = (year%400==0)||(year%100!=0&&year%4==0) ;
if(!flag&&day>28){
return false;
}
}
return true;
}
int main(){
int a,b,c;
set<int> date;
scanf("%d/%d/%d",&a,&b,&c);
int y=a+1900;
if(y<1960||y>2059){
y+=100;
}
date.insert(y*10000+b*100+c);
y=c+1900;
if(y<1960||y>2059){
y+=100;
}
date.insert(y*10000+a*100+b);
date.insert(y*10000+b*100+a);
for(set<int >::iterator it=date.begin();it!=date.end();it++){
int d=*it;
int day=d%100;
d/=100;
int month=d%100;
d/=100;
int year=d;
if(isright(year,month,day)){
printf("%04d-%02d-%02d\n",year,month,day);
}
}
return 0;
}