You May Already Have Won
One of the primary advantages of the method we've used so far to find the heaviest pumpkin(s) is that we didn't have to save the weights of all the pumpkins as we went along. If we don't mind saving all the weights, then we can solve the "three prize" problem in a different way. Let's assume for the purpose of simplicity that there are only five weights to be saved, in which case the solution looks like this:
Read in all of the weights.
Make a list consisting of the three highest weights in descending order.
Award the first, second, and third prizes, in that order, to the three entries in the list of highest weights.
Now let's break those down into substeps which can be more easily translated into C++:
Read in all of the ...
Get Learning to Program in C++ now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.