The standard library already have algorithms for finding max and min in a set of elements already, actually. You may want to try getting familiar with them as an exercise next.
They're called...