Little Jay

[C++] 백준 2587번 대표값2 본문

알고리즘/BOJ

[C++] 백준 2587번 대표값2

Jay, Lee 2021. 3. 5. 14:29
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {

	int input;
	int sum = 0, average = 0;
	vector<int> arr;

	for (int i = 0; i < 5; i++) {
		cin >> input;
		sum += input;
		arr.push_back(input);
	}

	average = sum / 5;
	sort(arr.begin(), arr.end());
	cout << average << "\n" << arr[2] << "\n";

	return 0;
}

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

[C++] 백준 2566번 최댓값  (0) 2021.03.06
[C++] 백준 2511번 카드놀이  (0) 2021.03.06
[C++] 백준 2750번 수 정렬하기  (0) 2021.03.05
[C++] 백준 2593번 대표값  (0) 2021.03.04
[C++] 백준 2748번 피보나치 수 2  (0) 2021.03.04
Comments