How to insert the second vector before the first? push_front not working!
#include <iostream> #include <vector> #include <conio.h> using namespace std; int main(int argc, char* argv[]) { int k = 1; int s = 0; int a[50]; vector<int>v1(5, 1); v1.clear(); v1.push_back(1); v1.push_back(3); v1.push_back(5); v1.push_back(4); v1.push_back(6); vector<int>v2(5, 1); v2.clear(); v2.push_back(7); v2.push_back(6); v2.push_back(0); v2.push_back(0); v2.push_back(9); cout << "Ishodnii Vector" << endl; cout << "Razmer v1: " << v1.size() << endl; for (int i = 0; i<v1.size(); i++) cout << " v1[" << i << "]=" << v1[i]; for (int i = 0; i <v1.size(); i++) s += v1[i]; cout << endl; for (int i = 0; i <v1.size(); i++) if (v1[i] == 1) v2.push_back(i); for (int i = 0; i<v1.size(); i++) { v2.push_back(i); k++; } cout << "\nRezultat Zadania" << endl; cout << "Razmer v1: " << v1.size() << endl; for (int i = 0; i<v1.size(); i++) cout << " v1[" << i << "]=" << v1[i]; cout << endl; getchar(); }
insert. - VladDvectoror is it better to add 1 to the end 2? - pavel