-------------------------------------
排序取中间数即可
AC代码:
1 import java.util.Arrays; 2 import java.util.Scanner; 3 4 public class Main { 5 6 public static void main(String[] args) { 7 8 Scanner sc=new Scanner(System.in); 9 10 int times=sc.nextInt(); 11 while(times-->0){ 12 int n=sc.nextInt(); 13 int x[]=new int[n]; 14 for(int i=0;i<x.length;i++) x[i]=sc.nextInt(); 15 Arrays.sort(x); 16 System.out.println(x[x.length/2]); 17 } 18 } 19 20 }