快速排序
#include <iostream>
using namespace std;
void QuickSort(int r[],int low,int high)
{
int temp;
int i=low,j=high;
if(low<high)
{
temp=r[low];
while(i<j)
{
while(j>i&&r[j]>=temp)j--;
if(i<j)
{
r[i]=r[j];
i++;
}
while(i<j&&r[i]<temp)i++;
if(i<j)
{
r[j]=r[j];
j--;
}
r[i]=temp;
QuickSort(r,low,i-1);
QuickSort(r,i+1,high);
}
}
}
int main()
{
int a[]={49,38,65,97,76,13,27,49};
QuickSort(a,0,7);
for(int i=0;i<=7;i++)
cout<<a[i]<<" ";
return 0;
}