Java 反而没人想用?
import java.util.Scanner;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
public class Nine {
public static void main(String[] args) {
System.out.print("Please input a number: ");
Scanner reader = new Scanner(System.in);
int n = reader.nextInt();
String pattern = "(\\d).*\\1";
Pattern r = Pattern.compile(pattern);
int count = 1;
for (int i = 0; i < (int) Math.pow(10, n); i++) {
Matcher m = r.matcher(String.valueOf(i));
if (!m.find()) {
System.out.printf("%d ", i);
count++;
}
if (count % 10 == 0) {
System.out.println("");
}
}
System.out.println("");
}
}
※ 引述《mikemagic88 (Mikemagic88)》之铭言:
: 使用者输入1 印1-9
: 使用者输入2 印1-98 (11, 22, 33等重复的不印)
: 使用者输入3 印1-987 (121, 988, 667等有重复的不印)