1C/C++/Java
21 gap = X;
32 do
43 { ok = 1;
54 for (i = 1; i<= N – gap; i++)
65 if (A[i] > A[i+gap])
76 { temp = A[i];
87 A[i] = A[i+gap];
98 A[i+gap] = temp;
109 ok = 0;
1110 }
1211 if (gap/2 > 1) gap=gap/2; else gap=1;
1312 } while (ok == 0);