Want to try solving this problem? You can submit your code online if you log in or register.
Input File: stacksin.txt
Output File: stacksout.txt
Time limit: 1 seconds
Implement a stack and show it off by writing a programme which
reads numbers from stacksin.txt. After each number, print out
the contents of the stack. If p
is given instead of a number,
pop the top item off the stack and then print its contents. If
is given, quit. If the stack is empty after a pop, print
'stack is empty!'.
You may assume that your stack does not grow beyond 100 levels deep.
1 2 3
stack is empty!