리스트 합치기

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 Python[ | ]

a = [11, 1]
b = [1, 12, 2]
c = a + b
print(c) # [11, 1, 1, 12, 2]
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}