题解 | #明明的随机数#
明明的随机数
https://www.nowcoder.com/practice/3245215fffb84b7b81285493eae92ff0
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
Integer n = Integer.parseInt(br.readLine());
ArrayList<Integer> list = new ArrayList<Integer>();
for (int i = 0; i < n; i++) {
Integer nums = Integer.parseInt(br.readLine());
if (i == 0) {
list.add(nums);
} else if (!list.contains(nums)) {
list.add(nums);
}
}
list.sort(new Comparator<Integer>() {
@Override
public int compare (Integer o1, Integer o2) {
return o1 - o2;
}
});
for (Integer intValue : list) {
System.out.println(intValue);
}
}
}