C++实现希尔排序
#pragma once void ShellSort(int* array, size_t n) { int gap = n; while (gap > 1) { gap = gap/3 + 1; for (size_t i = 0; i < n-gap; ++i) { int end = i; int tmp = array[end+gap]; while ((end >= 0) && array[end] > tmp) { array[end+gap] = array[end]; end -= gap; } array[end+gap] = tmp; } } }
当前题目:C++实现希尔排序
地址分享:http://myzitong.com/article/jsppjs.html