题解 | #明明的随机数# api给我冲!
明明的随机数
https://www.nowcoder.com/practice/3245215fffb84b7b81285493eae92ff0
import java.util.*;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
// 使用hash表存储数字
HashSet<Integer> set=new HashSet<>();
while (in.hasNextInt()) {
int n = in.nextInt();
int a = 0;
// 记录次数
for (int i = 0; i < n; i++) {
a = in.nextInt();
set.add(a);
}
// // 筛选只出现一次的数
ArrayList<Integer>list=new ArrayList<>();
for(Integer i:set){
list.add(i);
}
//排序
Collections.sort(list);
// 进行打印
for(Integer i: list){
System.out.println(i);
}
}
}
}
