Reverse Input with Reverse Iterators
mediumQuestion 568Write a program that reads whole numbers from standard input until there is no more input (end of file), stores them in a vector<int>, and then prints them in reverse order on one line, each number followed by a single space, ending with a newline. Use rbegin()/rend() to do the reversing — do not sort or use std::reverse.
The input is one or more integers separated by spaces or newlines, for example: 1 2 3 4
Expected output
4 3 2 1 8 7
= newline. The output ends with a newline, so print one after the last line.
Hints4 available
Sign in to use hintsTopics
STL ContainersIterators
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)
Your output
Run your code to see the output here...
Test cases
Run your code to see test case results.