Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void ShellSort(int n, int *arr, int &counter)
- {
- int i, j, step;
- int tmp;
- for (step = n / 2; step > 0; step /= 2)
- {
- for (i = step; i < n; i++)
- {
- tmp = arr[i];
- for (j = i; j >= step; j -= step)
- {
- ++counter;
- if (tmp < arr[j - step])
- {
- arr[j] = arr[j - step];
- }
- else
- {
- break;
- }
- }
- arr[j] = tmp;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement