package 每周算法;
import java.util.*;
public class week4 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
//利用集合直接实现去重排序
TreeSet<Integer> s = new TreeSet<>();
for (int i = 0; i < n; i++) {
s.add(sc.nextInt()) ;
}
//输出集合的长度
System.out.println(s.size());
//使用迭代器输出集合
Iterator it = s.iterator();
while (it.hasNext()){
System.out.print(it.next()+" ");
}
}
}
第四周题解
最新推荐文章于 2024-08-12 16:47:32 发布