c++将两个vector向量连接
1 #include <iostream> 2 #include <vector> 3 int main(int argc, char **argv) { 4 int arr[6] = {1,2,3,4,5,6}; 5 std::vector<int> v1(&arr[0],&arr[3]); 6 std::vector<int> v2(&arr[3],&arr[5]); 7 8 std::vector<int> v3; 9 v3.insert(v3.end(),v1.begin(),v1.end()); 10 v3.insert(v3.end(),v2.begin(),v2.end()); 11 12 for(int i = 0; i < v3.size(); i++) 13 { 14 std::cout << v3[i] << ", "; 15 } 16 std::cout << std::endl; 17 18 return 0; 19 }