#include <stdio.h>
void QuickSort(int a[], int left,int right);
void QuickSort(int a[], int left,int right) {
int i,j,t,temp;
if(left>right)
return;
temp= a[left];
i=left;
j=right;
while(i!=j)
{
while(a[j]>=temp && i<j) j--;
while(a[i]<=temp && i<j) i++;
if(i<j)
{
t=a[i];
a[i]=a[j];
a[j]=t;
}
}
a[left]=a[i];
a[i]=temp;
QuickSort(a, left,i-1);
QuickSort(a, i+1,right);
}
void Print(int a[], int n) {
for(int i = 0; i < n; i++) {
printf("%d ", a[i]);
}
}
int main() {
int array[10] = { 200, 11, 23, 55, 16, 29, 89, 99, 293, 18};
QuickSort(array, 0, 9);
Print(array, 10);
}
#include <stdio.h>
int Partition(int A[], int low, int high);
void QuickSort(int A[], int low, int high);
void QuickSort(int A[], int low, int high) {
if (low < high) {
int pivotpos = Partition(A, low, high);
QuickSort(A, low, pivotpos-1);
QuickSort(A, pivotpos+1, high);
}
}
int Partition(int A[], int low, int high) {
int pivot = A[low];
while(low < high) {
while(low < high && A[high] >= pivot) --high;
A[low] = A[high];
while(low < high && A[low] <= pivot) ++low;
A[high] = A[low];
}
A[low] = pivot;
return low;
}
void Print(int a[], int n) {
for(int i = 0; i < n; i++) {
printf("%d ", a[i]);
}
}
int main() {
int array[10] = { 200, 11, 23, 55, 16, 29, 89, 99, 293, 18};
QuickSort(array, 0, 9);
Print(array, 10);
}