Answer:
#include <iostream>
#include <vector>
using namespace std;
int main() {
vector<int> numberlist;
int number;
while (1) {
cout << "Enter a number: ";
cin >> number;
if (number == 0) break;
numberlist.push_back(number);
};
reverse(numberlist.begin(), numberlist.end());
for (int number : numberlist) {
cout << number << " ";
}
return 0;
}
Explanation:
There is a built-in function to reverse the contents of a vector.