#include<iostream>
using namespace std;
#include<stdio.h>
#include<stack>
#include<list>
#include<assert.h>
#define BUFFER_SIZE 256
void shellsort(int a[], int n)
{
int gap = n / 2;
while (gap >= 1)
{
for (int i = gap; i < n; ++i)
{
int j = i - gap;
int get = a[i];
while (j >= 0 && a[j] > get)
{
a[j + gap] = a[j];
j = j - gap;
}
a[j + gap] = get;
}
gap = gap / 2; // 递减增量
}
}
void main()
{
int a[] = { 16,25,12,30,47,11, 23,36,9,18,31 };
int n = sizeof(a) / sizeof(a[0]);
shellsort(a, n);
for (int i = 0; i < n; ++i)
{
cout << a[i] << " " << endl;
}
}