C++ rsort

Jmnote (토론 | 기여)님의 2023년 9월 17일 (일) 13:03 판 (새 문서: ==개요== ;C++ rsort ;C++ 역순 정렬 ;C++ 내림차순 정렬 ==벡터 정렬== <syntaxhighlight lang='cpp' run> #include <iostream> #include <vector> #include <algorithm> using...)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 개요

C++ rsort
C++ 역순 정렬
C++ 내림차순 정렬

2 벡터 정렬

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    vector<int> v = {11, 1, 12, 2};
    sort(v.begin(), v.end(), [](int a, int b) -> bool { return a > b; });
    for(int x: v) cout << x << ' '; // 12 11 2 1
}

3 같이 보기

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}