提取不重复的整数
提取不重复的整数
http://www.nowcoder.com/questionTerminal/253986e66d114d378ae8de2e6c4577c1
import java.util.Scanner; public class Main { private int cal(int number) { boolean[] marked = new boolean[10]; int result = 0; while (number != 0) { if (!marked[number % 10]) { result = result * 10 + number % 10; marked[number % 10] = true; } number /= 10; } return result; } public Main() { Scanner in = new Scanner(System.in); while (in.hasNextInt()) { int number = in.nextInt(); int result = cal(number); System.out.println(result); } } public static void main(String[] args) { Main solution = new Main(); } }