본문 바로가기

코딩테스트 예제

프로그래머스 배열의 평균값 구하기

class Solution {
    public double solution(int[] numbers) {
        int n = numbers.length;
        int a = 0;
        for(int i = 0; i < n; i++){
           a += numbers[i];
        }
        
        double answer = (double)a / n;
        return answer;
    }
}

'코딩테스트 예제' 카테고리의 다른 글

손코딩  (0) 2023.04.18
프로그래머스 옷가게 할인받기  (0) 2023.04.16
프로그래머스 피자나눠먹기3  (0) 2023.04.15
간단한 배열 정렬하기!  (0) 2023.04.15
프로그래머스 피자나눠먹기2 예제  (0) 2023.04.15