← Back to STL Containers
Question 512
Reverse Numbers from Input
Reverse Numbers from Input
Write a program that reads integers from standard input until the input ends, pushes each one onto a stack<int>, and then pops them all to print the numbers in reverse order on one line, separated by single spaces, followed by a newline.
The numbers may be separated by spaces or newlines, and there is always at least one number.
Input example:
1 2 3 4Expected Output:
4 3 2 1 30 20 10
= newline. The output ends with a newline — print one after the last line.
Hints4 available
Sign in to use hintsTopics:
STL ContainersStacks
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.