void shellSort1(T arr[], int n) { int h = 1; while (h < n / 3) h = 3 * h + 1; while (h >= 1) { for (int i = 0; i <= h - 1; i++) { for (int j = h + i; j < n; j += h) { T e = arr[j]; int k = j; for (k = j; k > 0 && e < arr[k - h]; k -= h) arr[k] = arr[k - h]; arr[k] = e; } } h /= 3; } }
我自己按照定义写了一遍不优化的shellSort, 可以运行但是最后的delete[]语句会卡住, Debug原因:A heap has been corrupted 什么原因怎么办呢?