日期顺逆序一致
#include <stdio.h>
#include <string.h>
int main()
{
int year,moth,day,sum,sumt,x,i,n;
for(year=2021; year < 2122; year++){
for(moth=1; moth < 13; moth++){
for(day=1; day < 32; day++){
sum = moth*100 + day;
x = sum;
sumt = 0;
for(i=0; x>0; i++){
n = x%10;
x = x/10;
sumt = sumt*10+n;
}
if(sumt<1000){
if(year == sumt*10)
printf("%d\n",year*10000 + moth*100 + day);
}else{
if(year == sumt)
printf("%d\n",year*10000 + moth*100 + day);
}
}
}
}
return 0;
}
结果