헤더 : #include <algorithm>
sort(start,end) -> [start,end) 범위 인자 오름차순(default)정렬
quick sort 기반으로 구현되어 있어 시간 복잡도는 n log n
사용법
1. sort(arr,arr+n);
2. sort(v.begin(),v.end());
3. sort(v.begin(),v.end(), compare); //사용자 정의 함수
4. sort(v.begin(),v.end(), greater<자료형>()); //내림차순
5. sort(v.begin(),v.end(), less<자료형>()); //오름차순
'C++' 카테고리의 다른 글
cout 소수점 고정 (0) | 2024.11.24 |
---|---|
string::find (0) | 2024.11.24 |
c++ string을 통 특정 문자 제거 (0) | 2024.11.24 |
string stream (0) | 2024.11.24 |
간단한 Queue 학습 및 제작 (0) | 2024.09.21 |