백준 자바 1546 1차원배열(평균)

임명수·2023년 5월 12일
0

백준

목록 보기
21/31

https://www.acmicpc.net/problem/1546


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        // 과목 N
        int N = Integer.parseInt(br.readLine());
        double [] scores = new double[N];
        StringTokenizer st = new StringTokenizer(br.readLine(), " ");

        for(int i=0; i <N; i++){
            scores[i] = Integer.parseInt(st.nextToken());
        }

        Arrays.sort(scores);

        double sum = 0;
        for(int i =0; i< scores.length; i++){
            sum+= scores[i]/scores[scores.length-1]*100;
        }
        System.out.println(sum / scores.length);

    }

}https://www.acmicpc.net/problem/1546
profile
푸른영혼의별

0개의 댓글