#include "stdio.h"
int partition(int a[], int low, int high){
int x = a[low];
while(low<high){
while(low<high && a[high]>=x){
--high;
}
a[low] = a[high];
while(low<high && a[low]<=x){
++low;
}
a[high] = a[low];
}
a[low] = x;
return low;
}
void QSort(int a[], int low, int high){
if(low<high){
int mid = partition(a, low, high);
QSort(a, low, mid);
QSort(a, mid+1, high);
}
}
int main(){
int a[]={23,232,323,4,8,65,9,65,45,78};
QSort(a,0,10);
for(int i=0; i<10; i++) {
printf(" %d ", a[i]);
}
}
int partition(int a[], int low, int high){
int x = a[low];
while(low<high){
while(low<high && a[high]>=x){
--high;
}
a[low] = a[high];
while(low<high && a[low]<=x){
++low;
}
a[high] = a[low];
}
a[low] = x;
return low;
}
void QSort(int a[], int low, int high){
if(low<high){
int mid = partition(a, low, high);
QSort(a, low, mid);
QSort(a, mid+1, high);
}
}
int main(){
int a[]={23,232,323,4,8,65,9,65,45,78};
QSort(a,0,10);
for(int i=0; i<10; i++) {
printf(" %d ", a[i]);
}
}