题解 | #明明的随机数#
明明的随机数
http://www.nowcoder.com/practice/3245215fffb84b7b81285493eae92ff0
import java.util.Scanner;
import java.util.TreeSet;
/**
* @ProjectName: leetcode
* @Package: com.company.niuke
* @ClassName: Main
* @Author: Administrator
* @Description: 牛客网测试
* @Date: 2022/2/11 20:30
* @Version: 1.0
*/
public class Main {
public static void main(String[] args) {
TreeSet<Integer> set = new TreeSet<>();
Scanner scanner = new Scanner(System.in);
while (scanner.hasNext()) {
int N = scanner.nextInt();
for (int i = 0; i < N; i++) {
set.add(scanner.nextInt());
}
for (Integer integer : set
) {
System.out.println(integer); //输出tree中的数据
}
set.clear(); //清空
}
}
}