首页 > 代码库 > NYOJ题目124中位数
NYOJ题目124中位数
-------------------------------------
排序取中间数即可
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 }
题目来源: http://acm.nyist.net/JudgeOnline/problem.php?pid=124
NYOJ题目124中位数
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。