procedure BubbleSort(arr: array of Integer); var i, j, temp: Integer; swapped: Boolean; begin swapped := True; for i := 0 to Length(arr) - 1 do begin if not swapped then break;
swapped := False; for j := 0 to Length(arr) - 2 do begin if arr[j] > arr[j + 1] then begin temp := arr[j]; arr[j] := arr[j + 1]; arr[j + 1] := temp; swapped := True; end; end;
procedure BubbleSort(arr: array of Integer);
swapped := False;var
i, j, temp: Integer;
swapped: Boolean;
begin
swapped := True;
for i := 0 to Length(arr) - 1 do
begin
if not swapped then
break;
for j := 0 to Length(arr) - 2 do
begin
if arr[j] > arr[j + 1] then
begin
temp := arr[j];
arr[j] := arr[j + 1];
arr[j + 1] := temp;
swapped := True;
end;
end;
end;
end;