#include
main()
{
int ar[100],i,n;
void quickshort(int[],int,int);
printf(“\n Enter size of array”);
scanf(“%d”,&n);
for(i=0; i<=n-1; i++)
{
printf(“\n Enter element”);
scanf(“%d”,&ar[i]);
}
printf(“\n array element before sorting”);
for(i=0; i<=n-1; i++)
{
printf(“\t%d”,ar[i]);
}
quicksort(ar,0,n-1);
printf(“\n array element after sorting”);
for(i=0; i<=n-1; i++)
{
printf(“\t%d”,ar[i]);
}
}
{
int v,temp,l,r;
l=first;
r=last-1;
v=ar[last];
while(i<=r)
{
While(ar[i]
l++;
while(ar[r]>v)
r--;
if(l<=r)
{
temp=ar[l];
ar[l]=ar[r];
ar[r]=temp;
l++;
r--;
}
}
Output:
Enter size of array5
Enter element402
Enter element401
Enter element403
Enter element405
Enter element404
array element before sorting402 401 403 405 404
array element before sorting401 402 403 404 405
No comments:
Post a Comment