Java 版本

字符串排序(1)

http://www.nowcoder.com/questionTerminal/251845265711496da75c59126725f76b

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

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int t = scanner.nextInt();
        String[] array = new String[t];
        for (int i = 0; i < t; ++i) {
            array[i] = scanner.next();
        }
        Arrays.sort(array);
        for (int i = 0; i < t; ++i) {
            if (i == t - 1) {
                System.out.println(array[i]);
                break;
            }
            System.out.print(array[i] + " ");
        }
    }
}
全部评论

相关推荐

7 收藏 评论
分享
牛客网
牛客企业服务