Algorithm

(Java) 평균 구하기(백준 1546)

Accept 2023. 6. 6. 14:02
public static void main(String[] args) {

    int count = 3;
    int[] scoreArray = {40, 80, 60};
    int maxScore = 0;
    int totalScore = 0;
    for (int score : scoreArray) {
        if (score > maxScore) {
            maxScore = score;
        }

        totalScore += score;
    }

    int renewalScore = totalScore * 100 / maxScore / count;
    System.out.println(renewalScore);
}