- package com.test;
- public class Test001 {
- public static void main(String[] args) {
- // 最小三位数:i = 123
- // 最大三位数:3 * i < 987
- String temp;
- for (int i = 123; i <= 987 / 3; i++) {
- temp = i + " " + 2 * i + " " + 3 * i;
- if (Test001.isExist(temp)) {
- System.out.println(temp);
- }
- }
- }
- private static boolean isExist(String temp) {
- if (!temp.contains("0")) {
- boolean bool = true;
- String arr[] = new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
- for (String element : arr) {
- if (temp.lastIndexOf(element) != temp.indexOf(element)) {
- bool = false;
- break;
- }
- }
- return bool;
- }
- return false;
- }
- }
- //该片段来自于http://www.codesnippet.cn/detail/140520149568.html
来源: http://www.codesnippet.cn/detail/140520149568.html