#include <iostream>
#include <algorithm>

using namespace std;


int partition(int array[], int left,int right){
	int pivot = array[right];
	int storeIndex = left;
	for(int i = left; i<right; i++){
		if(array[i]<pivot){
			swap(array[storeIndex],array[i]);
			storeIndex++;
		}
	}
	swap(array[storeIndex],array[right]);
	return storeIndex;
}


void quicksort(int a[],int i,int k){
	if(i<k){
		int p = partition(a,i,k);
		quicksort(a,i,p-1);
		quicksort(a,p+1,k);
	}
}


int main() {
	// array a to be sorted
	int a[] = {1,2,3,4,5,6,7,8,9,5,34,53,8};
	
	//finds the size of array a
	int n = sizeof(a)/sizeof(a[0]);
	
	//calls the quicksort function define above
	quicksort(a,0,n-1);
	
	//prints the sorted array
	for(int i = 0; i<n; i++){
		cout<<a[i]<<" ";
	}
	
	return 0;
}