Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int ks(0),kd(0);
- void Shell(vector <int> v, int sz)
- {
- ks = 0; kd = 0;
- cout << "Array: ";
- for(int i = 0; i < sz; ++i)
- cout << v[i] <<' ';
- cout << '\n';
- int d = sz / 3 + 1;
- while (true)
- {
- for (int i = d; i < sz; i++)
- {
- int key = v[i];
- int j = i - d;
- while (v[j] > key&& j >= 0)
- {
- ks++;
- v[j + d] = v[j];
- kd++;
- j -= d;
- }
- v[j + d] = key;
- kd++;
- }
- if (d == 1)
- break;
- d = d / 3 + 1;
- }
- cout << "Result: ";
- for (int i = 0; i < sz; ++i)
- cout << v[i] << ' ';
- cout << "\nSravnenii : " << ks << "\nDeistvii : " << kd << "\n\n";
- }
- int main()
- {
- int sz;
- int a;
- vector<int> v;
- cin>>sz;
- while(cin>>a)
- v.push_back(a);
- cout<<v[a]<<' ';
- Shell(v,sz);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement