Programming/Baekjoon

백준 2562 c++

fishersheep 2022. 1. 28. 23:54
반응형

백준: 최댓값

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>

using namespace std;


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	vector<pair<int,int>>v(9);

	for (int i = 0; i < 9; i++)
	{
		cin >> v[i].first;
		v[i].second = i+1;	//인덱스값 저장
	}


	sort(v.begin(), v.end());	//오름차순정렬

	cout << v[8].first << '\n';	//최댓값출력
	cout << v[8].second << '\n';	//최댓값인덱스



	return 0;
}
반응형

'Programming > Baekjoon' 카테고리의 다른 글

백준 10809 c++ 주석포함  (0) 2022.01.30
백준 10808 c++ 주석포함  (0) 2022.01.30
백준 10799 c++ 주석포함  (0) 2022.01.27
백준 9012 c++ 주석포함  (0) 2022.01.27
백준 11004 c++ 주석포함  (0) 2022.01.27