#include <iostream> using namespace std; void ShellSort(int* a,int n){ int Step = n/2; while(Step > 0){ for(int i=Step;i<n;i++){ int j = i - Step; int k = i; while(j >= 0){ if(a[k] < a[j]){ int t = a[j]; a[j] = a[k]; a[k] = t; } j = j-Step; k = k-Step; } } Step /= 2; } } int main() { int a[] = {2,5,8,9,4,6,1,3,7,0}; int n = 10; ShellSort(a,n); for(size_t i=0;i<10;i++){ cout << a[i] << " "; } return 0; }