Imagine you have a stack of papers in front of you, each with a number written on it. They are in no particular order. You can only pick up one sheet at a time, the one on top.
How would you find the largest and smallest of the numbers in the pile, and at any moment, if interrupted, be able to state which is the highest and lowest number you've found so far?
Consider also the case that there happens to be only one piece of paper on the stack.
Now do this in C++ code.
vmanes
Posting Virtuoso
1,914 posts since Aug 2007
Reputation Points: 1,268
Solved Threads: 228