#include <iostream>
using namespace std;
void quick(int arr[],int first,int last)
{
while(first<last)
{
int i=first;
int j=last;
int pivot=first;
while(i<=j)
{
if(arr[i]<arr[pivot] && i<j)
{
i++;
}
else if(arr[j]>arr[pivot])
{
j--;
}
else
{
swap(arr[i],arr[j]);
}
}
swap(arr[j],arr[pivot]);
quick(arr,0,j-1);
quick(arr,j+1,last);
}
}
int main()
{
int arr[5]={34,56,87,56,90};
int n=5;
quick(arr,0,n-1);
for(int i=0;i<n;i++)
{
cout<<"the sorted array is "<<arr[i];
}
return 0;
}
To embed this program on your website, copy the following code and paste it into your website's HTML: