Mega Code Archive

 
Categories / Delphi / Algorithm Math
 

Find minmax value of array

Title: Find min/max value of array Use Find_Max and Find_Min procedures, if you want to get maximum or minimum value from array, which contains 10 numbers. function Find_Max(Arr: array of Integer): Integer; var i, M: Integer; begin M:=Arr[Low(Arr)]; for i:=1 to High(Arr) do if Arr[i]&gtM then M:=Arr[i]; Result:=M; end; function Find_Min(Arr: array of Integer): Integer; var i, M: Integer; begin M:=Arr[Low(Arr)]; for i:=1 to High(Arr) do if Arr[i]&ltM then M:=Arr[i]; Result:=M; end;