Fork me on GitHub

NYOJ题目1080年龄排序

--------------------------

桶排都过不了,我彻底没办法了...

 1 import java.io.BufferedReader;
 2 import java.io.IOException;
 3 import java.io.InputStreamReader;
 4 
 5 public class Main{
 6 
 7     public static void main(String[] args) throws NumberFormatException, IOException {
 8         
 9         BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
10         
11         int n=Integer.parseInt(reader.readLine());
12         int book[]=new int[151];
13         String ss[]=reader.readLine().split(" ");
14         for(int i=0;i<n;i++) book[Integer.parseInt(ss[i])]++;
15         
16         StringBuilder sb=new StringBuilder();
17         for(int i=0;i<book.length;i++){
18             while(book[i]-->0) sb.append(i).append(" ");
19         }
20         
21         System.out.println(sb.toString());
22     }
23     
24 }

 

 

题目来源: http://acm.nyist.net/JudgeOnline/problem.php?pid=1080

posted @ 2016-09-16 03:02  CC11001100  阅读(215)  评论(0编辑  收藏  举报