Delphi-Quellcode:
program Project7;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils;
function GetMaxDoubleArrayIndex(
const DoubleArray:
array of Double): Integer;
var
i: Integer;
highest: Double;
begin
Result := -1;
highest := Low(Integer);
for i := Low(DoubleArray)
to High(DoubleArray)
do
if DoubleArray[i] > highest
then
begin
Result := i;
highest := DoubleArray[i];
end;
end;
var
TestArray:
array of Double;
i: Integer;
begin
try
Randomize;
SetLength(TestArray, 8);
for i := Low(TestArray)
to High(TestArray)
do
TestArray[i] := Random(100000);
for i := Low(TestArray)
to High(TestArray)
do
WriteLn('
#' + IntToStr(i) + '
= ' + FloatToStr(TestArray[i]));
WriteLn;
WriteLn('
Höchstwert hat Index #' + IntToStr(GetMaxDoubleArrayIndex(TestArray)));
ReadLn;
except
on E:
Exception do
Writeln(E.ClassName, '
: ', E.
Message);
end;
end.
kurz mal geschrieben, scheint zu funktionieren.