【华为机试】—— 3.明明的随机数

题目

解法

import java.util.*;

public class Main 
{
    public static void main(String[] args)
    {
        
        Scanner sc = new Scanner(System.in);
        
        while(sc.hasNext()){
            
            int num = sc.nextInt();
            
            TreeSet<Integer> set = new TreeSet<>();
            
            for(int i=0;i<num;i++){
                set.add(sc.nextInt());
            }
            
            for(Integer integer : set){
                System.out.println(integer);
            }
            
            
        }    
                                                                    
    }
}

猜你喜欢

转载自www.cnblogs.com/bopo/p/9258876.html