Bubble Sort - delphi

procedure  BubbleSort(var A: array of Integer);
var
  I, J, T: Integer;
begin

  for I := High(A) downto Low(A) do
    for J := Low(A) to High(A) - 1 do
      if A[J] > A[J + 1] then
      begin
           
        T := A[J];
        A[J] := A[J + 1];
        A[J + 1] := T;
       
      end;
end;

//=================================
// see as:

Selection Sort - delphi

Quick Sort -delphi

 

沒有留言:

張貼留言