import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.lang.*;
//基础练习 特殊回文数
public class Main {
public static void main(String[] args) {
huiwen();
}
static void huiwen() {
Scanner scanner = new Scanner(System.in);
int num = scanner.nextInt();
List<Integer> nums = new ArrayList<>();
for(int i = 10000; i < 1000000; i++) {
String item = String.valueOf(i);
StringBuilder sb = new StringBuilder();
sb.append(item);
StringBuilder sb1 = new StringBuilder();
String sb1Str = sb1.append(item).toString();
String sbStr = sb.reverse().toString();
if (sbStr.compareTo(sb1Str) == 0) {
int sum = 0;
for(int j = 0; j < sb.length(); j++) {
sum = sum + (sb.charAt(j) - '0');
}
if (sum == num) {
nums.add(i);
}
}
}
for(int i = 0; i < nums.size(); i++) {
System.out.println(nums.get(i));
}
}
}
蓝桥杯 特殊回文数
最新推荐文章于 2024-09-01 15:30:33 发布