作品说明
#include<iostream>
#include<ctime>
#include<cstdlib>
using namespace std;
Paritition(int A[], int low, int high) {
int pivot = A[low];
while (low < high) {
while (low < high && A[high] >= pivot) {
--high;
}
A[low] = A[high];
while (low < high && A[low] <= pivot) {
++low;
}
A[high] = A[low];
}
A[low] = pivot;
return low;
}
void QuickSort(int A[], int low, int high)
{
操作说明
if (low < high) {
int pivot = Paritition(A, low, high);
QuickSort(A, low, pivot - 1);
QuickSort(A, pivot + 1, high);
}
}
int main()
{
int i,k,b[100000];
srand(time(NULL));
for( i=0; i<100000;i++ )
{
b[i]=rand()%100000+1;
}
QuickSort(b,0,i-1);
for(int i = 0;i<100000;i++)
{
cout<<b[i]<<" ";
}
}