Who's in the Middle

http://acm.hdu.edu.cn/game/entry/problem/show.php?chapterid=1&sectionid=3&problemid=21
 1 //author:pz
 2 
 3 import java.io.BufferedInputStream;
 4 import java.util.Arrays;
 5 import java.util.Scanner;
 6 
 7 public class Main {
 8     public static void main(String[] args) {
 9         Scanner in = new Scanner(new BufferedInputStream(System.in));
10         while (in.hasNext()) {
11             int n = in.nextInt();
12             int[] arr = new int[n];
13             for (int i = 0; i < n; i++) {
14                 arr[i] = in.nextInt();
15             }
16             Arrays.sort(arr);
17             System.out.println(arr[arr.length / 2]);
18         }
19     }
20 }

 

posted on 2013-05-01 03:16  P,Z  阅读(163)  评论(0编辑  收藏  举报