C++ 벡터 벡터 정렬

1 개요[ | ]

C++ 벡터 벡터 정렬
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    vector<vector<int>> v = {{5,400},{3,300},{9,200},{0,100}};
    for(const vector<int>& row: v) {
        for(const int& cell: row) cout << cell << ' '; cout << "\n";
    }
}
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    vector<vector<int>> v = {{5,400},{3,300},{9,200},{0,100}};
    sort(v.begin(), v.end());
    for(const vector<int>& row: v) {
        for(const int& cell: row) cout << cell << ' '; cout << "\n";
    }
}
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    vector<vector<int>> v = {{5,400},{3,300},{9,200},{0,100}};
    sort(v.begin(), v.end(), [](auto a, auto b) {
        return a[1] < b[1];
    });
    for(const vector<int>& row: v) {
        for(const int& cell: row) cout << cell << ' '; cout << "\n";
    }
}

2 같이 보기[ | ]

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