Oscar A.

asked • 04/17/20

Write a program that reads a list of integers, and outputs those integers in reverse.

Write a program that reads a list of integers, and outputs those integers in reverse. The input begins with an integer indicating the number of integers that follow. For coding simplicity, follow each output integer by a space, including the last one.

Ex: If the input is:

5 2 4 6 8 10

the output is:

10 8 6 4 2

To achieve the above, first read the integers into a vector. Then output the vector in reverse.


#include <iostream>

#include <vector> // Must include vector library to use vectors

using namespace std;


int main() {

vector<int> userInts; // A vector to hold the user's input integers


/* Type your code here. */


return 0;

}


1 Expert Answer

By:

Patrick B. answered • 04/17/20

Tutor
4.7 (31)

Math and computer tutor/teacher

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.