题解 | #明明的随机数#
明明的随机数
https://www.nowcoder.com/practice/3245215fffb84b7b81285493eae92ff0
import java.util.Iterator; import java.util.Scanner; import java.lang.Integer; import java.util.TreeSet; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int total=Integer.parseInt(in.nextLine()); TreeSet<Integer> tSet= new TreeSet<Integer>(); for(int i=1;i<=total;i++){ int cur=Integer.parseInt(in.nextLine()); tSet.add(cur); } Iterator<Integer> it=tSet.iterator(); while(it.hasNext()){ System.out.println(it.next()); } } }