← Back to STL Containers
Question 568
Reverse Input with Reverse Iterators
Reverse Input with Reverse Iterators
Write a program that reads whole numbers from standard input until there is no more input (end of file), stores them in avector<int>, and then prints them in reverse order on one line, each number followed by a single space, ending with a newline. Userbegin()/rend()to do the reversing — do not sort or usestd::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 — 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.