标签:没有 com ons 目录 笔记 技术分享 数位 color logs
目录
具体代码如下:
import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; public class Main { public static int n; public void getResult() { ArrayList<Integer> result = new ArrayList<Integer>(); for(int i = 10000;i < 1000000;i++) { String temp = i + ""; if(temp.length() == 5) { if(temp.charAt(0) == temp.charAt(4) && temp.charAt(1) == temp.charAt(3)) { int num = i % 10 * 2 + i / 10 % 10 * 2 + i / 100 % 10; if(num == n) result.add(i); } } else if(temp.length() == 6) { if(temp.charAt(0) == temp.charAt(5) && temp.charAt(1) == temp.charAt(4) && temp.charAt(2) == temp.charAt(3)) { int num = i % 10 * 2 + i / 10 % 10 * 2 + i / 100 % 10 * 2; if(num == n) result.add(i); } } } if(result.size() == 0) System.out.println("-1"); else { Collections.sort(result); for(int i = 0;i < result.size();i++) System.out.println(result.get(i)); } } public static void main(String[] args) { Main test = new Main(); Scanner in = new Scanner(System.in); n = in.nextInt(); test.getResult(); } }
标签:没有 com ons 目录 笔记 技术分享 数位 color logs
原文地址:http://www.cnblogs.com/liuzhen1995/p/6814900.html