#include #include #include #include //for inserter and back_inserter #include //for copy using namespace std; int main() { const int a[] = {10, 21, 31, 41, 50, 90}; const size_t na = sizeof a / sizeof a[0]; vector v(a, a + na); //Overwrite the 21, 31, 41 with 20, 30, 40. //The third argument in line 18 refers to the 21. const int b[] = {20, 30, 40}; const size_t nb = sizeof b / sizeof b[0]; copy(b, b + nb, v.begin() + 1); //Insert 60, 70, 80 in front of the 90. //The third argument in line 24 refers to the 90. const int c[] = {60, 70, 80}; const size_t nc = sizeof c / sizeof c[0]; copy(c, c + nc, inserter(v, v.begin() + 5)); //Insert 100, 110, 120 at the end of the vector. const short d[] = {100, 110, 120}; const size_t nd = sizeof d / sizeof d[0]; copy(d, d + nd, back_inserter(v)); for (vector::const_iterator it = v.begin(); it != v.end(); ++it) { cout << *it << " "; } cout << "\n"; return EXIT_SUCCESS; }