[Java] Do it! 코딩테스트 - 자료구조(7.29)

EunBi Na·2022년 7월 29일
0

public class 평균 구하기
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
   		int N = sc.nextInt();
    	int A[] = new int[N];
        for (int i = 0; i < N; i++) {
        	A[i] = sc.nextInt();
        }
        long sum = 0;
        long max = 0;
        for (int i = 0; i < N; i++) {
        	if(A[i] > max) max = A[i];
            sum = sum + A[i];
        }
       System.out.println(sum + 100.0 / max / N);
     }
  }

profile
This is a velog that freely records the process I learn.

0개의 댓글