题解 | #明明的随机数#
明明的随机数
https://www.nowcoder.com/practice/3245215fffb84b7b81285493eae92ff0
public static void main(String[] args) { Scanner sc = new Scanner(System.in); int size = sc.nextInt(); ArrayList<Integer> input = new ArrayList<Integer>(size); while(sc.hasNext()){ input.add(sc.nextInt()); } input.sort(Comparator.naturalOrder()); for(int i=0; i<size; i++){ if(input.size()>i+1){ if(input.get(i)==input.get(i+1)) continue; System.out.println(input.get(i)); }else{ System.out.println(input.get(i)); } } }简单易懂, java循环