알고리즘/삼성 SW expert Academy

[SWEA] 2063. 중간값 찾기_JAVA

뇌장하드 2022. 5. 4. 19:50

https://swexpertacademy.com/main/code/problem/problemDetail.do

 

SW Expert Academy

SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!

swexpertacademy.com

 

import java.util.Scanner;
import java.io.FileInputStream;
import java.util.Arrays;

class Solution
{
    public static void main(String args[]) throws Exception
    {
     Scanner sc = new Scanner(System.in);
 
        int n=sc.nextInt();
        int[] a=new int[n];
        for(int i=0;i<n;i+=1) {
            a[i]=sc.nextInt();
        }
        Arrays.sort(a);
        System.out.println(a[n/2]);
        }
     
}