Skip to content

Commit 8684586

Browse files
committed
Level1 배열 평균구하기
1 parent c78e72a commit 8684586

7 files changed

Lines changed: 19 additions & 0 deletions

File tree

879 Bytes
Binary file not shown.
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package programmers;
2+
3+
public class Level1AverageArray {
4+
public double solution(int[] arr) {
5+
double answer = 0;
6+
for (int i = 0; i < arr.length; i++) {
7+
answer += arr[i];
8+
System.out.println(arr[i]);
9+
}
10+
answer = answer / arr.length;
11+
return answer;
12+
}
13+
14+
public static void main(String[] args) {
15+
Level1AverageArray a = new Level1AverageArray();
16+
int [] arr = {1, 2 ,3, 4};
17+
System.out.println(a.solution(arr));
18+
}
19+
}

0 commit comments

Comments
 (0)