void quicksort(int arr[], const int BEGIN, const int END) { if (BEGIN >= END) { return; } int i = BEGIN + 1; int j = END; while(i < j) { if (arr[i] > arr[BEGIN]) { swap(&arr[i], &arr[j]); j--; } else { i++; } } //cout << i << " " << j << endl; if (arr[i] >= arr[BEGIN]) { i--; } swap(&arr[i], &arr[BEGIN]); quicksort(arr, BEGIN, i); quicksort(arr, j, END); }