C++/백준 C++

[C/C++] 백준 30684번 모르고리즘 회장 정하기

CE : 하랑 2023. 11. 21. 19:45

 

 

 

 

 

코드

 

#include <iostream>
#include <vector>
#include <algorithm> // sort

using namespace std;

int main()
{
	int n;

	vector<string> name;

	cin >> n;

	for (int i = 0; i < n; i++) {
		string str;

		cin >> str;

		if (str.size() == 3) { // 이름이 세 글자인 사람만 name에 추가
			name.push_back(str);
		}
	}

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

	cout << name[0]; 

	return 0;
}