I am new in C++.
I need to copy a vector in reverse order to another vector.
Here's how i did it :
int temp[] = {3, 12, 17};
vector<int>v(temp, temp+3);
vector<int>n_v;
n_v=v;
reverse(n_v.begin(), n_v.end()); //Reversing new vector
Is there any simple way to copy a vector in reverse order to another vector in STL?
Simply just do this:
vector<int>n_v (v.rbegin(), v.rend());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With