C++ 벡터 합치기

1 개요[ | ]

C++ 벡터 합치기
#include <iostream>
#include <vector>
using namespace std;

int main() {
    vector<int> a = {11, 1};
    vector<int> b = {1, 12, 2};
    
    vector<int> c;
    c.reserve(a.size()+b.size());
    c.insert(c.end(), a.begin(), a.end());
    c.insert(c.end(), b.begin(), b.end());
    for(int n: c) cout << n << ' '; // 11 1 1 12 2
}

2 같이 보기[ | ]

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