How to pick the highest value in a variable array?

Stardragon

Member!
Joined
Nov 9, 2003
Messages
106
Reaction score
0
Location
Sweden
Website
www.beelzebub.se
I have an integer array in which I've stored 9 players' number of kills. Now I want to make a trigger which selects the player with most kills and let him win.

Does anyone know a nice way to accomplish this?
 

ChrisH36

Guy with Most Posts on Quiet Board.
Joined
May 20, 2003
Messages
15,042
Reaction score
4
Location
Temple Prime, Sarajevo
I remember seeing someting like this in Turing, I will load up WE and see how I can help you.
 

Galmore

Member
Joined
Apr 25, 2006
Messages
11
Reaction score
0
Id do a for loop with a if then stament

iHighest_so_far = 0

For A = 1 to 9 do
if iArray[A] > iHighest_so_far then
iHighest_so_far = A
loop

Winner = iHighest_so_far


That make sence to ya?
 

ChrisH36

Guy with Most Posts on Quiet Board.
Joined
May 20, 2003
Messages
15,042
Reaction score
4
Location
Temple Prime, Sarajevo
Yes, the Bubble Sort Method is probably the best way to do it.
 

NewPosts

New threads

Top