본문 바로가기

CodingTest Exam/[C++] Algorithm Study

32. 선택정렬 (it 취업을 위한 알고리즘 문제풀이 입문 (with C/C++) : 코딩테스트 대비) ★☆☆☆☆

#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;
int main()
{
	int n;
	scanf("%d", &n);
	
	vector<int> num(n, 0);
	for(int i = 0; i < num.size(); i++)
		scanf("%d", &num[i]);
		
	
	sort(num.begin(), num.end());
	
	for(int i = 0; i < num.size(); i++)
		printf("%d ", num[i]);
		
	return 0;
}

1. <algorithm> 헤더의 sort(s_idx, l_idx) 활용

s_idx부터 l_idx까지 오름차순으로 정렬한다.