package 算法;
import java.util.Scanner;
public class 回文数 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);//创建一个键盘扫描类对象
int n = input.nextInt();
n = n / 10000;
int[] a1 = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int[] a2 = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int flag = 0;
for (int i = n; i < 9000; i++) {
if (Is_Leapyear(i)){
flag=0;
}else {
flag=1;
}
for (int j = 1; j <= 12; j++) {
for (int k = 1; k <= (flag == 0 ? a2[j] : a1[j]); k++) {
int N = i * 10000 + j * 100 + k;
if (N / 10000000 == N % 10 &&
N / 1000000 % 10 == N / 10 % 10 &&
N / 100000 % 10 == N / 100 % 10 &&
N / 10000 % 10 == N / 1000 % 10) {
System.out.println(N);
return;
}
}
}
}
}
static boolean Is_Leapyear(int year)
{
if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
return true;
else
return false;
}
}
2020年第十一届蓝桥杯省赛c/c++b组回文数
最新推荐文章于 2025-07-15 12:03:49 发布