Computer Science/C++

백준 C++ | #3 BOJ1546 평균 C++ 풀이

토마토. 2022. 7. 27. 15:08
#include <iostream>

int main() {
	int N;
	std::cin >> N;
	
	double* exam = new double[N];
	double max = 0;
	for (int i = 0; i < N; i++) {
		std::cin >> exam[i];
		if (exam[i] > max) {
			max = exam[i];
		}
	}

	double sum = 0;
	for (int i = 0; i < N; i++) {
		exam[i] = (exam[i] / max) * 100;
		sum += exam[i];
	}

	double n = N;
	double mean = sum / n;
	std::cout << mean << std::endl;


	return 0;
}