比较相距一定间隔的元素,间隔不断缩小
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; } }
时间: 2024-10-11 21:49:52