#include <iostream> using namespace std; void swap(int &a, int &b) { int c = a; a = b; b = c; } int Partition(int *A,int p,int r) { int x = A[r]; int i = p-1; for(int j = p; j<=r-1; ++j) { if(A[j] <=x) { i++; swap(A[i],A[j]); } } swap(A[i+1],A[r]); return i+1; } void QuickSort(int *A, int p, int r) { //int q =0; if(p < r) { int q = Partition(A,p,r); QuickSort(A,p,q-1); QuickSort(A,q+1,r); } } void printArray(int *A) { for(int i =0; i < 10;++i) { cout << A[i]<<" "; } } int main() { int array[]={16,14,10,8,7,9,3,2,4,1}; QuickSort(array,0,9); printArray(array); cout <<endl; return 0; }