#include <stdio.h>
void ShellSort(int array[], int length)
{
int i, j;
int h;
int temp;
for (h = length / 2; h > 0; h = h / 2)
{
for (i = h; i < length; i++)
{
temp = array[i];
for (j = i - h; j >= 0; j -=h)
{
if (temp < array[j])
{
array[j + h] = array[j];
}
else
{
break;
}
}
array[j + h] = temp;
}
}
}
int main()
{
int i = 0;
int a[] = {0, 5, 2, 4, 3, 1, 7, 6, 8, 9};
int length = sizeof (a) / sizeof(a[0]);
ShellSort(a, length);
for (i = 0; i < length; i++)
{
printf("%d ", a[i]);
}
printf("\n");
return 0;
}
void ShellSort(int array[], int length)
{
int i, j;
int h;
int temp;
for (h = length / 2; h > 0; h = h / 2)
{
for (i = h; i < length; i++)
{
temp = array[i];
for (j = i - h; j >= 0; j -=h)
{
if (temp < array[j])
{
array[j + h] = array[j];
}
else
{
break;
}
}
array[j + h] = temp;
}
}
}
int main()
{
int i = 0;
int a[] = {0, 5, 2, 4, 3, 1, 7, 6, 8, 9};
int length = sizeof (a) / sizeof(a[0]);
ShellSort(a, length);
for (i = 0; i < length; i++)
{
printf("%d ", a[i]);
}
printf("\n");
return 0;
}