//quick sorting of integers
#include
#include
void sort(int a[],int first,int last)
{
int temp,low,high,mid;
low=first;
high=last;
mid=a[(first+last)/2];
do
{
while(a[low] < mid)
low++;
while(a[high] > mid)
high--;
if(low <=high)
{
temp=a[low];
a[low]=a[high];
a[high]=temp;
low++;
high--;
}
}
while(low <= high);

if(first < high)
{
sort(a,first,high);
}
if(low < last)
{
sort( a,low,last);
}
}

void main()
{
int a[10],i,n;
printf("\n enter the size of the array -->");
scanf("%d",&n);
printf("\n enter array elements one by one \n");
for(i=0;i

Comments (0)

CSS Menu Samples