happy coding

[java] 1546. 평균 본문

coding study/baekjoon

[java] 1546. 평균

yeoonii 2023. 8. 13. 00:50
import java.io.*;
import java.util.*;

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

        int N = Integer.parseInt(br.readLine());
        double sum = 0.0;
        int max = -1;

        StringTokenizer st = new StringTokenizer(br.readLine());

        for (int i=0 ; i<N ; i++) {
            int value = Integer.parseInt(st.nextToken());

            if (value > max) {
                max = value;
            }

            sum += value;
        }
        double mean = (double) (sum/max)*100.0 / N;

        System.out.println(mean);
    }
}
Comments