C++ 페어 벡터

1 개요[ | ]

C++ pair vector
C++ 페어 벡터
#include <iostream>
#include <vector>
#include <utility>
using namespace std;
int main() {
    vector<pair<int,int>> points;
    points.push_back({2,20});
    points.push_back({4,40});
    points.push_back({1,10});
    points.push_back({3,30});
    
    for(const auto& p: points) {
        cout << p.first << ", " << p.second << endl;
    }
}
#include <iostream>
#include <vector>
#include <utility>
using namespace std;
int main() {
    vector<pair<int,string>> points;
    points.push_back({2,"David"});
    points.push_back({4,"Carol"});
    points.push_back({1,"Bob"});
    points.push_back({3,"Alice"});
    
    for(const auto& p: points) {
        cout << p.first << ", " << p.second << endl;
    }
}

2 같이 보기[ | ]

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