백준2587: 대표값2
문제
https://www.acmicpc.net/problem/2587
문제 풀이
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = 5;
ArrayList<Integer> list = new ArrayList<>();
for (int i = 0; i < n; i++) {
list.add(sc.nextInt());
}
Collections.sort(list);
int sum = 0;
for (Integer integer : list) {
sum += integer;
}
System.out.println(sum / n);
System.out.println(list.get(2));
}
}
댓글남기기