解题思路:
注意事项:
参考代码:
import java.awt.List; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; import java.util.Scanner; import javax.print.attribute.HashAttributeSet; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int hui = sc.nextInt(); for (int i = 10000; i <= 999999; i++) { //判断是否是回文数 boolean b = true; String st = String.valueOf(i); int len = st.length(); for (int j = 0; j < len/2; j++) { if (st.charAt(j) != st.charAt(len-1-j)) { b = false; } } //判断数字之和是否是n函数 if (b == true) { char[] arr = String.valueOf(i).toCharArray(); int sum = 0; for (int k = 0; k < arr.length; k++) { sum += (arr[k]-'0'); } if (sum == hui) { System.out.println(i); } } } } }
0.0分
3 人评分