#include<iostream>
using namespace std;
int Partition(int a[],int left,int right){
int temp=a[left];
while(left<right){
while(right>left && a[right]>=temp) right--;
a[left]=a[right];
while(left<right && a[left]<=temp) left++;
a[right]=a[left];
}
a[left]=temp;
return left;
}
void quicksort(int a[],int left,int right){
if(left<right){
int pos=Partition(a,left,right);
quicksort(a,left,pos-1);
quicksort(a,pos+1,right);
}
}
void bubble_sort(int a[],int n){
int temp;
for(int i=0;i<n;i++){
for(int j=i;j<n;j++){
if(a[i]>a[j]){
a[j]=temp;
a[j]=a[i];
temp=a[i];
}
}
}
}
void select_sort(int a[],int n){
for(int i=0;i<n;i++){
int k=i;
for(int j=i;j<n;j++){
if(a[k]>a[j])
k=j;
}
int temp=a[i];
a[i]=a[k];
a[k]=temp;
}
}
void insertsort(int a[],int n){
for(int i=1;i<n;i++){
int temp=a[i];
int j=i;
while(j>0 && temp<a[j-1]){
a[j]=a[j-1];
j--;
}
a[j]=temp;
}
}
void main(){
int a[11]={35,18,16,72,24,65,12,88,46,28,55};
quicksort(a,0,10);
for(int i=0;i<11;i++)
cout<<a[i]<<" ";
cout<<endl;
bubble_sort(a,11);
for(int j=0;j<11;j++)
cout<<a[j]<<" ";
cout<<endl;
select_sort(a,11);
for(int m=0;m<11;m++)
cout<<a[m]<<" ";
cout<<endl;
insertsort(a,11);
for(int n=0;n<11;n++)
cout<<a[n]<<" ";
cout<<endl;
}