void shellsort(int a[],int n)
{
int i,j,temp,inc=n/2-1;
while(inc>0)
{
for(i=inc;i<n;i++)
{
temp=a[i];
j=i-inc;
while(j>=0 && a[j]>temp)
{
a[j+inc]=a[j];
j=j-inc;
}
a[j+inc]=temp;
}
inc=inc/2;
}
for(i=0;i<n;i++)
{
printf("%d ",a[i]);
}
getch();
}
int main()
{
int a[]={1,5,7,2,0,-1,5,43,23,60};
shellsort(a,10);
}
This blog will cover all important aspects of 'C' 'C++', 'Data Structures in C' and other Technical stuffs. In this blog you will find good C Interview Questions Answers. I will be posting both multiple choice and subjective type C interview questions and answers. Tutorials will be posted from time to time that will focus on problem solving.
Sunday, October 2, 2011
Shell Sort C program for Dev C++
Labels:
sorting
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment