源代码如下:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define ARRAYLENGTH 30
#define RANGE 100
void swap(int& key1,int& key2){
int temp = key1;
key1 = key2;
key2 = temp;
}
int partition(int A[],int p,int r){
int x = A[r];
int i = p - 1;
for(int j=p;j<r;++j){
if(A[j] <= x){
i += 1;
swap(A[i],A[j]);
}