{求 a[i]: 大於或等於其前所有的數,小於或等於其後的所有的數}
procedure TForm1.btn1Click(Sender: TObject);
var
inta: array[1..10] of Integer;
i, j: Integer;
IntS: string;
begin
Ints := '';
inta[1] := 3;
inta[2] := 4;
inta[3] := 8;
inta[4] := 2;
inta[5] := 9;
inta[6] := 10;
inta[7] := 19;
inta[8] := 11;
inta[9] := 20;
inta[10] := 17;
for i := 1 to 10 do
begin
IntS := IntS + IntToStr(inta[i])+', ';
end;
mmo1.Lines.Add(IntS);
for i := 1 to 10 do
begin
for j := 1 to 10 do
if ((j<=i) and (inta[j] > Inta[i])) or ((j>=i) and (inta[j] < Inta[i])) then Break;
if (j>10) then mmo1.Lines.Add(IntToStr(inta[i]));
end;
end;