输入一组数字返回该组数据可组成的最大数

public static void main(String[] args) {
        while (true) {
            Scanner sc = new Scanner(System.in);
            int n = sc.nextInt();
            Scanner sc2 = new Scanner(System.in);
            List<String> list=new ArrayList<>(n);
            while(sc2.hasNext()){
                    list.add(sc2.next());
                if(list.size()>n-1)break;
            }
            Collections.sort(list);
            Collections.reverse(list);
            String val="";
            for (String s :
                    list) {
                val+=s;
            }
            System.out.println(val);
        }
    }

 

posted @ 2018-08-23 15:37  天涯已可  阅读(339)  评论(0编辑  收藏  举报