#include<iostream>
using namespace std;
int partition(int a[], int low, int high){
int i=low;
int j=high;
int temp=a[i];
while(i!=j){
while(i<j&&a[j]>temp)
j--;
if(i<j)
a[i++]=a[j];
while(i<j&&a[i]<temp)
i++;
if(i<j)
a[j--]=a[i];
}
a[i]=temp;
return i;
}
void quicksort(int a[], int low, int high){
if(low>=high)
return;
int m=partition(a, low, high);
quicksort(a, low, m-1);
quicksort(a, m+1, high);
}
void bubblsort(int a[], int n){
int temp;
for(int i=0;i<n-1;i++)
for(int j=0;j<n-1-i;j++)
if(a[j]>a[j+1]){
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
int main(){
int a[]={3,5,1,4};
quicksort(a, 0, 3);
for (int i=0; i<4; i++) {
cout<<a[i]<<' ';
}
cout<<endl;
}