일상

1546 : 평균

STUDYING,,, 2021. 7. 28. 23:42
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		double[] score = new double[sc.nextInt()];
		double sum = 0;
		double avg = 0;

		for (int i = 0; i < score.length; i++) {
			score[i] = sc.nextInt();
		}

		double maxScore = 0;
		for (int i = 0; i < score.length; i++) {
			if (maxScore < score[i]) {
				maxScore = score[i];
			}

		}

		for (int i = 0; i < score.length; i++) {
			score[i] = score[i] / maxScore * 100;
		}

		for (int i = 0; i < score.length; i++) {
			sum += score[i];
		}
		avg = sum / score.length;

		System.out.println(avg);

	}
}

'일상' 카테고리의 다른 글

4344 : 평균은 넘겠지  (0) 2021.07.29
8958 : OX퀴즈  (0) 2021.07.29
3052 : 나머지  (0) 2021.07.28
2577 : 숫자의 개수  (0) 2021.07.27
2562 : 최댓값  (0) 2021.07.26