Java 版

字符串排序(3)

http://www.nowcoder.com/questionTerminal/0588d343472e42a9af1eda9a69912df3

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

public class Main {

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

相关推荐

点赞 评论 收藏
分享
16 收藏 评论
分享
牛客网
牛客企业服务