#include #include #include #include using namespace std; #define N 20 void sort_shell(vector* v){ for(int gap = v->size()/2; gap>0; gap/=2){ for(int i = gap; i < v->size(); i++){ int temp = v->at(i); int j; for(j=i; j >= gap && v->at(j-gap) > temp; j-=gap){ v->at(j) = v->at(j-gap); } v->at(j) = temp; } } } void sort_heap_heapify(vector* v, int n, int i){ int smallest = i; int left = 2 * i + 1; int right = 2 * i + 2; if(left < n && v->at(left) < v->at(smallest)){ smallest = left; } if(right < n && v->at(right) < v->at(smallest)){ smallest = right; } if(smallest != i){ swap(v->at(i), v->at(smallest)); sort_heap_heapify(v, n, smallest); } } void sort_heap(vector* v){ for(int i = v->size()/2 - 1; i>=0; i--){ sort_heap_heapify(v, v->size(), i); } for(int i = v->size() - 1; i>0; i--){ swap(v->at(0), v->at(i)); sort_heap_heapify(v, i, 0); } } int main(){ ios::sync_with_stdio(false); vector v; srand(time(NULL)); cout<<"The vector:\n"; for(int i=0; i par; vector impar; for(int i=0; i