1 #include <iostream> 2 using namespace std; 3 void shellsort(int v[],int n) 4 { 5 int gap,i,j,temp; 6 for (gap = n/2 ; gap >0 ; gap /= 2) 7 { 8 for (i = gap; i < n ; ++i) 9 { 10 for (j = i - gap ; j >=0 && v[j] > v[j+gap] ; j -= gap) 11 { 12 temp = v[j]; 13 v[j] = v[j + gap]; 14 v[j+gap] = temp; 15 } 16 } 17 } 18 } 19 20 void main() 21 { 22 int v[] = {10,32,12,24,55,11,63,84,1,3,76}; 23 shellsort(v,11); 24 for (int i = 0; i <11;i++) 25 { 26 cout<<v[i]<<" "; 27 } 28 cout<<endl; 29 }