| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 
 | #include<iostream> #include<algorithm>
 using namespace std;
 int a[6]={3,6,1,4,5,2},n=6;
 void quicksort(int f,int l)
 {
 if(f>=l) return ;
 int i=f;
 int j=l;
 int X=a[i];
 while(i<j)
 {
 while(a[j]>=X&&i<j)
 j=j-1;
 swap(a[i],a[j]);
 while(a[i]<=X&&i<j)
 i=i+1;
 swap(a[i],a[j]);
 }
 quicksort(f,j-1);
 quicksort(j+1,l);
 }
 int main()
 {
 quicksort(0,n);
 for(int i=0;i<n;i++)
 cout<<a[i]<<" ";
 return 0;
 }
 
 |