题解 | #明明的随机数#
明明的随机数
https://www.nowcoder.com/practice/3245215fffb84b7b81285493eae92ff0
import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner scanner = new Scanner(System.in); int count = scanner.nextInt(); Set<Integer> numSet = new HashSet(count); for(int i=0; i<count; i++){ int num = scanner.nextInt(); numSet.add(num); } List<Integer> numList = new ArrayList<>(numSet.size()); for(Integer num: numSet){ numList.add(num); } Collections.sort(numList); for(int i=0; i<numList.size(); i++){ System.out.println(numList.get(i)); } } }
#牛客求职必刷题#