Question
C++ What am I missing here? #include #include using namespace std; void reverse(vector &a) { // a = { 1,2,3,4,5 }; cout < < The
C++ What am I missing here?
#include
void reverse(vector
cout << "The normal vector: "; for (unsigned i = 0; i <= 4; i++) { cout << a.at(i) << " "; } cout << endl;
cout << "The reversed vector: "; for (unsigned i = 0; i <= a.size()/2; i++) { int temp = a.at(i); a.at(i) = a.at(a.size() - 1 - i); a.at(a.size() - 1 - i) = temp; cout << a.at(i) << " "; } cout << endl; } int main() { vector
//When I try to reverse the vector, I get 5 4 3, how do I get 2 1?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started