Program to reverse a vector without using a temporery variable.

Recommended Answers

All 3 Replies

swap finrst and last member increase count for first , decrease count for last do the same......repeat...........

STL provides you with the reverse() algorithm.
I.e.

std::reverse(your_vector.begin(), your_vector.end());

You need to #include <algorithm> to make it compile.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.