完整代码:
#include
#include
#include
#include
#include
#include
using namespace std;
struct Pair {
int left;
int right;
};
const int MAX_PROCESS = 128;
const int NUM = 8000;
const int MAX = 1000000;
const int MIN = 0;
int arr[NUM];
int temp[NUM];
Pair pairs[MAX_PROCESS];
int counter = -1;
void swap(int A[], int i, int j) {
int temp = A[i];
A[i] = A[j];
A[j] = temp;
}
int findpivot(int i, int j) {
return (i + j) / 2;
}
int partition(int A[], int l, int r, int pivot) {
do {
while (A[++l] < pivot);
while ((r != 0 && (A[--r] > pivot)));
swap(A, l, r);
} w