希尔排序: 希尔排序是插入排序的一种,是针对直接插入排序算法的改进。该方法又称缩小量排序,因DL.Shell于1959年提出而得名。 基本思路: 先取一个小于n的整数d1作为第一个增量,把文件的全部记录分组。所有距离为d1的倍数的记录放在同一个组中。先在各组内进行直接插入排序;然后,取第二个增量d2 0; step /= 2)/设置步长 for(i = 0; i = 0 k -= step; arrk+step = temp; void CSort:sellSort2(int arr, int len) int i , step; for(step = len/2; step 0; step /= 2) for(i = step; i = 0 k -= step; arrk+step = temp; void CSort:sellSort3(int arr, int len) for(int step = len/2; step 0; step /= 2) for(int i = step; i = 0 k -= step) swap(