본문으로 바로가기
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

백준알고리즘


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


예시는 두 가지 과목을 주었고 문제 예시에는 3가지 과목을 주어서 약간 혼동이 있었다.

문제 설명에 대한 예제가 3가지 과목을 입력받고 40 + 80 + 60 / 최고점(80) * 100 / 3(입력받은 과목)



import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in); 
        int count = Integer.parseInt(scan.nextLine().trim());
        int[] calArray = new int[count];
        
        int max = 0;
        int total = 0;
        
        for(int i = 0; i < count; i++) {
            calArray[i] = (scan.nextInt());
            max = Math.max(max, calArray[i]);
            total += calArray[i];
        }
        
        int average = total * 100 / max ;
        
        System.out.printf("%.2f",(float)average / calArray.length);
    }
}