计算机生成了N个1到1000之间的随机整数(N≤1000),去重,然后从小到大排序。
明明的随机数
http://www.nowcoder.com/questionTerminal/3245215fffb84b7b81285493eae92ff0
1、去重
2、排序
3、去掉个数
import java.util.*; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while (scanner.hasNext()) { TreeSet<Integer> out = new TreeSet<>(); Integer size = Integer.valueOf(scanner.next()); for (int i = 0; i < size; i++) { out.add(Integer.valueOf(scanner.next())); } out.forEach( x-> System.out.println(x)); } } }