比较相距一定间隔的元素,间隔不断缩小
for (increment=N/2; increment>0; increment/=2) { for (i=increment; i<N; i++) { tmp = A[i]; for (j=i; j>=increment; j-=increment) { if (tmp < A[j-increment]) { A[j] = A[j-increment]; } else break; } A[j] = tmp; } }
原文:http://www.cnblogs.com/m2492565210/p/7257689.html