shell sort



//implement shell sorting
#include<iostream.h>
#include<math.h>
#include<conio.h>
const int size=10;
void main()
{
int a[size],gap,i,j,temp;
clrscr();
cout<<"\n\Enter elements in array\n";
for(i=0;i<size;i++)
cin>>a[i];
gap=size/2;
while(gap>0)
{
i=gap;
while(i<size)
{
temp=a[i];
j=i;
while(j>=gap && temp<a[j-gap])
{
a[j]=a[j-gap];
j=j-gap;
}
a[j]=temp;
i++;
}
gap=ceil(gap/2);
}
i=0;
cout<<"\nsorted array by shell sorting is\n";
while(i<size)
{
cout<<"\na["<<i<<"]"<<a[i];
i++;
}
getch();
}
*******output*******







No comments:

Post a Comment

using avrdude with AVR studio(for windows 10 only)

Requirements 1. arduino-1.6.5-r2-windows.exe 2. as6installer-6.0.1843.exe When I try to configure avrdude in avr studio 6 then wina...