- void shellsort(int *data, size_t size)
- {
- for (int gap = size / 2; gap > 0; gap /= 2)
- for (int i = gap; i < size; ++i)
- {
- int key = data[i];
- int j = 0;
- for( j = i -gap; j >= 0 && data[j] > key; j -=gap)
- {
- data[j+gap] = data[j];
- }
- data[j+gap] = key;
- }
- }
- //该片段来自于http://www.codesnippet.cn/detail/1509201410419.html
来源: http://www.codesnippet.cn/detail/1509201410419.html