function newGap(gap : Integer):integer; begin gap := trunc(gap / 1.3); //wymagany moduł "math" if (gap = 9) OR (gap=10) then gap := 11; //warunek tylko dla Combsort 11 if gap < 1 then gap := 1; newGap:=gap; end;

var gap, i, j : Integer; x : Integer; swapped : Boolean; begin gap := n; repeat gap := newGap(gap); swapped := false; for i := 0 to n-gap-1 do begin j := i + gap; if a[i] > a[j] then begin x := a[i]; a[i] := a[j]; a[j] := x; swapped := true; end; end; until (gap = 1) and (not swapped); end;

Przypisy

Grzebieniowe