快速排序:
#include <stdio.h>
int partition(int a[],int low,int high){
int temp=a[low];
int tp;
int i=low,j=low+1;
for(;j<=4;j++){
if(a[j]<temp){
tp=a[i];
a[i]=a[j];
a[j]=tp;
i++;
}
if(a[low]!=temp){
low=j;
}
}
if(i!=low){
temp=a[i];
a[i]=a[low];
a[low]=temp;
low=i;
}
return low;
}
void quicksort(int a[],int low,int high){
if(low < high){
int mid;
mid = partition(a,low,high);
quicksort(a,low,mid-1);
quicksort(a,mid+1,high);
}
}
int main(){
int a[5]={4,5,1,8,3};
int low=0, high=4;
quicksort(a,low,high);
for(int i=0;i<5;i++)
printf("%d",a[i]);
}