// cpp array quick sort#include<iostream>using namespace std;void print(int a[], int n){ for(int j = 0; j < n; j++) { cout << a[j] << ' '; } cout << endl;}void swap(int *a, int *b){ int tmp = *a; *a = *b; *b = tmp;}int partition(int a[], int low, int high){ int privotKey = a[low]; while(low < high) { while(low < high && a[high] >= privotKey) --high; swap(&a[low], &a[high]); while(low < high && a[low] <= privotKey) ++low; swap(&a[low], &a[high]); } print(a, 8); return low;}void quickSort(int a[], int low, int high){ if(low < high) { int privotLoc = partition(a, low, high); quickSort(a, low, privotLoc -1); quickSort(a, privotLoc + 1, high); }}int main(){ int a[8] = {1, 5, 3, 6, 2, 4, 8, 7}; cout << "initial value: "; print(a, 8); quickSort(a, 0, 7); cout << "result: "; print(a, 8);}