PDA

View Full Version : GetMaxArrVal(array:TIntegerArray; var arrayIndex:Integer):Integer;



Sin
03-20-2013, 02:41 AM
function GetMaxArrayValue(a:TIntegerArray; var arrayIndex:Integer):Integer;
var
j,bigInt,tempInt,arrayVal:Integer ;
begin
for j := 0 to High(a) do
begin
tempInt := a[j];
if (tempInt > bigInt) then
begin
bigInt := a[j];
arrayVal := j;
end;
end;
Result := bigInt;
arrayIndex := arrayVal;
end;

What this basically does is that you input an array into 'a', and a variable where you want to store the index at which it's located.

Example:
exampleArray := [0,1,3,6,8,2,3,4,7];
The result will be 8, and 5 will be stored at arrayIndex.

Inb4somethinglikethisalreadyexists.

SRL Compiled in 0 msec
8
Time taken to do calculation: 0
Successfully executed.


As you can see it's pretty fast.. lol

Le Jingle
03-20-2013, 02:59 AM
MaxA()
AMax()
?

Sin
03-20-2013, 03:01 AM
Shoot me.