回文日期
lyc20120119 · · 个人记录
注意事项:日期要是合法的
#include<bits/stdc++.h>
using namespace std;
int a[]={0,31,29,31,30,31,30,31,31,30,31,30,31};
bool hui(int x){
int y=0,tmp=x;
while(tmp!=0){
y=y*10+tmp%10;
tmp/=10;
}
return x==y;
}
bool checkab(int x){
int n1=x/1000000,n2=x/10000%100;
if(n1==n2&&n1%10!=n1/10){
return true;
}
return false;
}
bool isdate(int x){
int m=x/100%100;
int day=x%100;
if(m>=1&&month<=12&&day>=1&&day<=a[m])
return true;
return false;
}
int main(){
int n,cnt=0;
cin>>n;
for(int i=n+1;;i++){
if(isdate(i)){
if(cnt==0&&hui(i)==true){
cnt++;
cout<<i<<endl;
}
if(cnt==1&&hui(i)==true&&checkab(i)==true){
cout<<i<<endl;
return 0;
}
}
}
return 0;
}