View Single Post
abacus
abacus is offline
#6
Aug12-04, 05:55 AM
P: 21
so something like this?

void RandQuickSort(int Array[], int l, int r) {

	int piv=l+(rand()%(r-1+1);
	swap(Array[1],Array[piv]);
	int i = l+1;
	int j = r;
	while (1) {
		while(Array[i] <= Array[1] && i<r) ++i;
	while (Array[j] <= Array[l] && j>l) -j;
	if (i >=j) {
		swap(Array[j],Array[l]);
	return j;
	}
	else Swap(Array[i],Array[j]);
}