Find biggest value

Blitz3D Forums/Blitz3D Programming/Find biggest value

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Oh, I see now. Yes it would be quicker. Something like the code below?

[Code]
Graphics 640,480,32,2
SeedRnd(MilliSecs())

; Create a list of random numbers
Global N=10
Temp$=""
Dim List(N)
For V=1 To N
List(V)=Rand(0,255)
Temp$=Temp$+Str(List(V))+"," ; <-- Just for the report
Next

; Now find the smallest & largest number in the list
Biggest=Get_Biggest_Number()
Smallest=Get_Smallest_Number()

Text 10,10,"REPORT"
Text 10,40,"List = "+Temp$
Text 10,70,"Biggest Number = "+Str(Biggest)
Text 10,90,"Smallest Number = "+Str(Smallest)
Flip
WaitKey():End

; **********************************************

Function Get_Biggest_Number()
Biggest=List(1)
For V=2 To N
If List(V)>Biggest
Biggest=List(V)
EndIf
Next
Return Biggest
End Function

; **********************************************

Function Get_Smallest_Number()
Smallest=List(1)
For V=2 To N
If List(V)<Smallest
Smallest=List(V)
EndIf
Next
Return Smallest
End Function

; **********************************************

[/Code]