shellsort排序算法思想是先比较距离远的元素,比较元素之间的距离逐渐减少,最后减到为1.
void shellsort(int num[], int n)
{
int number, i, j, temp;
for (number = n/2; number > 0; number /= 2)
{
for (i = number; i < n; i++)
{
for (j = i -number; j >=0 && num[j] > num[j+number]; j -= number)
{
temp = num[j];
num[j] = num[j+number];
num[j+number] = temp;
}
}
}
}