题解 | #字符串排序#

字符串排序

http://www.nowcoder.com/practice/0425aa0df74646209d3f56f627298ab2

import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; public class Main{ public static void main(String[] args)throws IOException{ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int M = Integer.parseInt(in.readLine()); int[] m = new int[M]; int i = 0; String str = null; // ArrayList arr = new ArrayList<>(); while((str = in.readLine())!= null){ m[i++] = Integer.valueOf(str.substring(str.length() - 6)) ; // String[] s = str.split(" "); // for(String temp : s){ // arr.add(Integer.valueOf(temp.substring(temp.length() - 6))); // // int len = temp.length(); // // char[] ch = new char[6]; // // for(int i = 5;i >= 0;i--){ // // ch[i] = temp.charAt(--len); // // } // // String st = new String // // arr.add(Integer.parseInt(ch)); // }

    }
   
    Arrays.sort(m);
    for(int t:m){
        System.out.println(t);
    }
}

}

全部评论

相关推荐

头像
04-02 20:00
点赞 评论 收藏
转发
点赞 收藏 评论
分享
牛客网
牛客企业服务