#include <stdio.h>
#include <conio.h>
#define MAX_SIZE 50
#define TRUE 1
#define FALSE 0
void main(void);
void shell_sort(double x[],int n);
void main(void)
{
double x[MAX_SIZE];
int num_items;
int i;
printf("\nSHELL SORT ORNEGI");
printf("\nSiralanacak sayi adedi (MAX=50) : ");
scanf("%d",&num_items);
for (i = 0; i < num_items; i++)
{
printf("%d. sayi : ",i+1);
scanf("%lf",&x[i]);
}
shell_sort(x, num_items);
printf("Sayilarin siralanmis hali : ");
for (i = 0; i < num_items; i++)
printf(" %.lf ",x[i]);
getch();
}
void shell_sort(double x[], int n)
{
double temp;
int i;
int last;
int is_sorted;
int jump = n / 2;
while (jump >= 1)
{
last = n - jump;
is_sorted = FALSE;
while (!is_sorted)
{
is_sorted = TRUE;
for(i = 0; i < last; ++i)
{
if (x[i] >= x[i + jump])
{
temp = x[i];
x[i] = x[i + jump];
x[i + jump] = temp;
is_sorted = FALSE;
}
}
}
jump = jump / 2;
}
}
#Shell Sort