#include <iostream>
using namespace std;
void shellSort(int *a, int n)
{
int gap,i,j,temp;
for (gap = n / 2; gap > 0;gap /= 2)
{
for (i = gap; i < n;i++)
{
if (a[i]<a[i-gap])
{
temp = a[i];
j = i - gap;
for (; j >= 0 && a[j] > temp;j-=gap)
{
a[j + gap] = a[j];
}
a[j + gap] = temp;
}
}
}
}
int main(int argc, char *argv[])
{
int a[10] = {5,3,4,8,6,1,2,9,7,10};
shellSort(a, 10);
for (int i = 0; i < 10;i++)
{
cout << a[i] << " ";
}
cout << endl;
system("pause");
return 0;
}