📅  最后修改于: 2022-03-11 15:00:03.343000             🧑  作者: Mango
Pascal
1 gap := X;
2 repeat
3 ok := 1;
4 for i := 1 to N - gap do
5 if A[i] > A[i+gap] then
6 begin temp:=a[i];
7 A[i]:=A[i+gap];
8 A[i+gap] := temp;
9 ok := 0
10 end;
11 if gap div 2>1 then gap:=gap div 2 else gap:=1
12 until ok=1;