본문 바로가기

알고리즘/백준

평균

#include <iostream>
using namespace std;

int main()
{
	int num;
	double arr[1000];
	double max = 0.0;
	double avg = 0.0;

	cin >> num;

	for (int i = 0; i < num; i++)
		cin >> arr[i];

	for (int j = 0; j < num; j++)
	{
		if (arr[j] >= max)
			max = arr[j];
	}

	for (int k = 0; k < num; k++)
		avg += ((arr[k] / max)*100.0);

	cout << avg/num;
	cout << '\n';
	return 0;
}

'알고리즘 > 백준' 카테고리의 다른 글

평균은 넘겠지  (0) 2019.09.26
OX퀴즈  (0) 2019.09.25
나머지  (0) 2019.09.22
숫자의 개수  (0) 2019.09.21
음계  (0) 2019.09.19