The fast sequencing in the classical sorting algorithm has good efficiency, but its realization is relatively difficult to understand.
#include <stdio.h>
int partition (int num[],int low,int High)//key for the column to be ranked as a "tall", "low" two parts, "high" part of the data is larger than key, "low" part of the data is smaller than key
{
int Left,right,key;
Left=low;right=high;key=num[low];
while (Left<right)
{
while (Left<right && Num[right]>=key)
right--;
Num[left]=num[right];
while (Left<right && Num[left]<=key)
left++;
Num[right]=num[left];
}
Num[left]=key;
return left;
}
void Quick_sort (int num[],int low,int High)//recursive implementation Quick sort
{
if (Low
{
int pos=partition (Num,low,high);
Quick_sort (NUM,LOW,POS-1);
Quick_sort (Num,pos+1,high);
}
}
int main ()
{
int data[10]={32,33,21,14,36,7,6,4,2,11};
int i;
for (i=0;i<10;i++)
printf ("%d", data[i]);
printf ("\ n");
Quick_sort (data,0,9);
for (i=0;i<10;i++)
printf ("%d", data[i]);
printf ("\ n");
}
Common sorting algorithm--quick sort (C language +vc6.0 platform)