반응형
[ 문제 ]
중간값은 통계 집단의 수치를 크기 순으로 배열 했을 때 전체의 중앙에 위치하는 수치를 뜻한다.
입력으로 N 개의 점수가 주어졌을 때, 중간값을 출력하라.
import java.util.*;
import java.io.FileInputStream;
class Solution
{
public static void main(String args[]) throws Exception
{
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
int num[] = new int[T];
int md = T/2;
for(int test_case = 0; test_case < T; test_case++)
{
num[test_case] = sc.nextInt();
}
Arrays.sort(num);
System.out.println(num[md]);
}
}

반응형
'코딩테스트 > SW Expert Academy' 카테고리의 다른 글
| [SWEA][D1] 연월일 달력(JAVA) (0) | 2023.11.09 |
|---|---|
| [SWEA][D1] 자릿수 더하기(JAVA) (2) | 2023.11.09 |
| [SWEA][D1] 최대수 구하기(JAVA) (0) | 2023.11.07 |
| [SWEA][D1] 큰 놈, 작은 놈, 같은 놈(JAVA) (0) | 2023.11.07 |
| [SWEA][D1] 평균값 구하기(JAVA) (0) | 2023.11.07 |