6.拼数(字符串)

6.拼数(字符串)_第1张图片
题目

import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();
		String[] str = new String[n];
		for(int i=0;i<n;i++)
			str[i] = sc.next();
		Arrays.sort(str,(o1,o2)->(o2+o1).compareTo(o1+o2));
		StringBuilder str1 = new StringBuilder();
		for(String x:str)
			str1.append(x);
		System.out.print(str1);		
		sc.close();
	}
}

你可能感兴趣的:(蓝桥杯省赛(Java组),java,开发语言)