CJCoding With Joseph
15free / daySign inCreate account

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 4

Expected Output:

4 3 2 1
30 20 10

= newline. The output ends with a newline — print one after the last line.

Hints4 available
Topics:
STL ContainersStacks
📥 Auto-Input:
1 2 3 4\n
This input is automatically fed to your program's stdin
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.