#include
#include
#define n 10
class shellsort{
static int A[n];
public:
void InsSort(int start, int step);
void ShellSort();
void tampil();
};
int
shellsort::A[n]={20,23,120,56,78,50,12,89,10,12};
void
shellsort::InsSort(int start, int step)
{
int i,j,y;
bool ketemu;
i=start+step;
while(i<=n)
{
y=A[i];
j=i-step;
ketemu=false;
while((j>=0)&&(!ketemu))
{
{
A[j+step]=A[j];
j=j-step;
}
else
ketemu=true;
}
A[j+step]=y;
i=i+step;
}
}
void
shellsort::ShellSort()
{
int step,start;
step=n;
while(step>1)
{
step=step/3+1;
for(start=1;start<=step;start++)
shellsort::InsSort(start,step);
}
}
void shellsort::tampil(){
for(int
a=0;a<10 a="" o:p="">10>
{
}
cout<
}
void main()
{
shellsort x;
cout<<"PENGURUTAN
SHELL"<
cout<<"Sebelum diurut :
"<
x.tampil();
x.ShellSort();
cout<<"Setelah diurut :
"<
x.tampil();
getch();
}