No, there is a much better way to do it. You don't need any swapping or sorting. Just make sure to choose the correct initial value before you get to the array.
Joined: Apr 08, 2004
Just make sure to choose the correct initial value before you get to the array. I do not understand this statement.
Joined: Oct 13, 2005
Before you start searching, you need a value for max or whatever your largest result is to be. Choosing the wrong value for that will, of course, mean you fail to find the correct maximum. The same applies if you are looking for second largest.