#include<stdio.h> int Partition(int A[],int low,int high) { int pivot=A[low]; while(low<high) { while(low<high&&A[high]>=pivot) --high; A[low]=A[high]; while(low<high&&A[low]<=pivot) ++low; A[high]=A[low]; } A[low]=pivot; return low; } void QuickSort(int A[],int low,int high) { if(low<high) { int pivotpos=Partition(A,low,high); QuickSort(A,low,pivotpos-1); QuickSort(A,pivotpos+1,high); } } int main(){ int a[]={27,38,13,49,76,97,65,49}; QuickSort(a,0,7); for(int i=0;i<8;i++) { printf("%d,",a[i]); } }
原文:https://www.cnblogs.com/upupup-999/p/15253072.html