I'm trying to find the highest two numbers in an array, and once these are found correspond them to another array.
Anyone have any idea how to do so?
Thanks.
Printable View
I'm trying to find the highest two numbers in an array, and once these are found correspond them to another array.
Anyone have any idea how to do so?
Thanks.
Probably the simplest way is to sort your array of numbers and then pick out the first two.
Two simple algorithms:
Insertion sort
Selection sort