import java.util.Scanner; public class OrderTest { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); boolean[] numberOrderArray = new boolean[1024]; int number; do { System.out.println("next number"); number = scanner.nextInt(); if(number<1024&&number>0) { numberOrderArray[number]=true; } } while (number!=0); for (int i = 0; i < numberOrderArray.length; i++) { if(numberOrderArray[i]) System.out.println(i); } } }
很好的一个排序方法,输入一组数据,去重复,排序,尽管有一定的限制条件