Monday, May 11, 2009

C-PROGRAM FOR QUICK SORT

#include
void quick(int a[],int,int);
void main()
{
int a[20],i,j,n,l,u;
printf("\nenter size of the array");
scanf("%d",&n);
printf("\nenter elements of the array");
for(i=0;ip)
j--;
if(i<=j)
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
else
{
temp=a[j];
a[j]=a[l];
a[l]=temp;
}
quick(a,l,j-1);
quick(a,j+1,u);
}
}
}

No comments:

Post a Comment