반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- 프로그래머스 가운데 글자 가져오기 python
- docker remove
- 핸즈온 머신러닝
- 코드업 1020 자바
- m1 docker install
- 프로그래머스 나누어 떨어지는 숫자 배열 자바
- 가운데 글자 가져오기 파이썬
- 빅분기실기
- 청년 AI Big Data 아카데미 13기
- 청년 Ai Big Data 아카데미
- docker 삭제
- 트리의 지름 java
- 프로그래머스 나누어 떨어지는 숫자 배열 파이썬
- m1 docker
- 최소 스패닝 트리 자바
- 최소 스패닝 트리
- 가운데 글자 가져오기 java
- 최단 경로 알고리즘
- 트리의 지름 자바
- docker 완전 삭제
- 가운데 글자 가져오기 python
- codeup 1020 java
- 가운데 글자 가져오기 자바
- 프로그래머스 가운데 글자 가져오기 자바
- codeup 1020 자바
- 나누어 떨어지는 숫자 배열 java
- 프로그래머스 가운데 글자 가져오기 파이썬
- 코드업 1020 java
- 빅데이터분석기사
- 나누어 떨어지는 숫자 배열 python
Archives
- Today
- Total
NineTwo meet you
[프로그래머스/파이썬/자바] 평균 구하기 본문
반응형
문제 & 제한사항 & 예제
더보기
문제 설명
정수를 담고 있는 배열 arr의 평균값을 return하는 함수, solution을 완성해보세요.
제한사항
- arr은 길이 1 이상, 100 이하인 배열입니다.
- arr의 원소는 -10,000 이상 10,000 이하인 정수입니다.
입출력 예
arr | return |
[1,2,3,4] | 2.5 |
[5,5] | 5 |
코드
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
public double solution(int[] arr) { | |
double answer = 0; | |
for(int i = 0; i < arr.length; i++){ | |
answer += arr[i]; | |
} | |
answer/=arr.length; | |
return answer; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def solution(arr): | |
return sum(arr) / len(arr) |
반응형
'프로그래밍 문제 > 프로그래머스' 카테고리의 다른 글
[프로그래머스/파이썬/자바] [1차]비밀지도 (0) | 2020.08.22 |
---|---|
[프로그래머스/파이썬/자바] 핸드폰 번호 가리기 (0) | 2020.08.22 |
[프로그래머스/파이썬/자바] 제일 작은 수 제거하기 (0) | 2020.08.22 |
[프로그래머스/파이썬/자바] 자릿수 더하기 (0) | 2020.08.22 |
[프로그래머스/파이썬/자바] 자연수 뒤집어 배열로 만들기 (0) | 2020.08.22 |