1 import java.util.*; 2 3 public class Main { 4 public static void main(String[] args) { 5 Scanner scanner = new Scanner(System.in); 6 int n = scanner.nextInt(); 7 int o,t,th,f,fi,s,before,behind,total = 0; 8 for (int i = 10000; i < 100000; i++) { 9 o = i%10;//个位 10 t = (i/10)%10;//十位 11 th = (i/100)%10;//百位 12 f = (i/1000)%10;//千位 13 fi = (i/10000); 14 behind =10*o+t; 15 before = 10*fi+f; 16 total = o+t+th+f+fi; 17 if(before==behind&&n==total){ 18 System.out.println(i); 19 } 20 } 21 22 for (int i = 100000; i < 1000000; i++) { 23 o = i%10;//个位 24 t = (i/10)%10;//十位 25 th = (i/100)%10;//百位 26 f = (i/1000)%10;//千位 27 fi = (i/10000)%10; 28 s = (i/100000); 29 behind = 100*o+10*t+th; 30 before = 100*s+10*fi+f; 31 total = o+t+th+f+fi+s; 32 if(before==behind&&n==total){ 33 System.out.println(i); 34 } 35 } 36 } 37 }
标签:10,特殊,behind,th,total,fi,回文,before From: https://www.cnblogs.com/Fangithub/p/17210899.html