There is a vector vector<int>v
I want to add another vector vector<int>temp
in the reverse order with this vector.
For instance,
v = {1, 5, 7} and temp = {11, 9, 8}
I want to add temp in reverse order, that is, {8, 9, 11}
in the vector v
.
So v
will be: v = {1, 5, 7, 8, 9, 11}
Here is how I did it:
int a[] = {1, 5, 7}; vector<int>v(a,a+3); int b[] = {11, 9, 8}; vector<int>temp(b,b+3); for(int i=temp.size()-1;i>=0;i--) v.push_back(temp[i]); for(int i=0;i<v.size();i++) cout<<v[i]<<" "; cout<<"\n";
Is there a built-in function in STL or C ++ for this? or do i need to do it manually?
user4379008
source share