We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Learn more about funding links in repositories.
Report abuse
1 parent 1f7b01b commit 75cb7d6Copy full SHA for 75cb7d6
4.shellSort.md
@@ -148,20 +148,19 @@ function shellSort($arr)
148
## 7. C++ 代码实现
149
150
```cpp
151
-void shellSort(vector<int>& nums) {
+void shellSort(vector<int>& arr) {
152
int gap = 1;
153
- while (gap < (int)nums.size() / 3) {
+ while (gap < (int)arr.size() / 3) {
154
gap = gap * 3 + 1;
155
}
156
for (; gap >= 1; gap /= 3) {
157
for (int i = 0; i < gap; ++i) {
158
- for (int j = i + gap; j < nums.size(); j += gap) {
159
- for (int k = j; k - gap >= 0 && nums[k] < nums[k - gap]; k -= gap) {
160
- swap(nums[k], nums[k - gap]);
+ for (int j = i + gap; j < arr.size(); j += gap) {
+ for (int k = j; k - gap >= 0 && arr[k] < arr[k - gap]; k -= gap) {
+ swap(arr[k], arr[k - gap]);
161
162
163
164
165
166
-
167
```
0 commit comments