본문 바로가기
알고리즘풀이/백준-자바

[백준/JAVA] 1546번 평균

by 이얏호이야호 2020. 7. 23.

import java.util.Scanner;


public class Main {

public static void main(String args[]) {

Scanner in = new Scanner(System.in);

int input = in.nextInt();

double[] arr = new double[input];

double max,average = 0;

for (int i = 0; i < input; i++) {

arr[i] = in.nextDouble();

}

max = arr[0];

for (int i = 0; i < input; i++) {

if (max < arr[i])

max = arr[i];

}

for (int i = 0; i < input; i++) {

arr[i] = arr[i] / max * 100;

average += arr[i];

}

System.out.println(average/input);

}

}

더 많은 백준 코드가 보고 싶다면 ?  https://chuinggun.tistory.com/category/%EB%B0%B1%EC%A4%80


댓글