#define SWAP(x,y,t) ((t)=(x),(x)=(y),(y)=(t))
void quick_sort(int* list,int left,int right){
if(left<right){
int q=partition(list,left,right);
quick_sort(list,left,q-1);
quick_sort(list,q+1,right);
}
}
int partition(int* list,int left,int right){
int pivot,temp;
int low,high;
low=left;
high=right+1;
pivot=list[left];
do{
do
low++;
while(list[low]<pivot);
do
high--;
whiel(list[high]>pivot);
if(low<high) SWAP(list[loq],list[high],temp);
}while(low<high);
SWAP(list[left],list[high],temp);
return high;
}
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
typedef struct{
int key;
}element;
element list[MAX];
#define SWAP(x,y,t) ((t)=(x),(x)=(y),(y)=(t))
#define MAX 100
void quicksort(element int* list,int left, int right){
int pivot,i,j;
element temp;
if(left<right){
i=left;
j=right+1;
pivot=list[left].key;
do{
do{
i++;
}while(list[i].key<pivot);
do{
j--;
}while(list[j].key>pivot);
if(i<j)
SWAP(list[i],list[j],temp);
}while(i<j);
SWAP(list[left],list[j],temp);
quicksort(list,left,j-1);
quicksort(list,j+1,right);
}
}