Algorithm/SWEA

[swexpert] 2063. 중간값 찾기

반응형

[swexpert] 1204. 최빈수 구하기


문제 링크


https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV5QPsXKA2UDFAUq&categoryId=AV5QPsXKA2UDFAUq&categoryType=CODE



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import java.util.Arrays;
import java.util.Scanner;
 
public class Solution_2063 {
 
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        
        int ts = s.nextInt(); // 테스트 케이스
        
        int[] data = new int[ts];
        
        for (int i = 0; i < data.length; i++) { // 데이터 수만큼 숫자 입력
            data[i] = s.nextInt();
        }
        
        Arrays.sort(data); // 정렬
        
        System.out.print(data[(data.length/2)]); // 중간값 출력
    }
 
}
cs


반응형

'Algorithm > SWEA' 카테고리의 다른 글

[swexpert] 1225. 암호생성기  (0) 2019.01.11
[swexpert] 1206. View  (0) 2019.01.11
[swexpert] 5431. 민석이의과제체크하기  (0) 2019.01.08
[swexpert] 1208. Flatten  (0) 2019.01.08
[swexpert] 1204. 최빈수 구하기  (0) 2019.01.07