题解 | #字符串排序#

字符串排序

http://www.nowcoder.com/practice/5af18ba2eb45443aa91a11e848aa6723

注意要消耗掉换行符

import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        scanner.nextLine();  //消耗掉换行符
        String[] strs = new String[n];
        for(int i = 0; i < n; i++){
            strs[i] = scanner.nextLine();
        }

        Arrays.sort(strs);
        for(String str : strs){
            System.out.println(str);
        }
    }
}
全部评论

相关推荐

05-20 13:59
门头沟学院 Java
米黑子米黑子:你这个成绩不争取下保研?
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务