#define MAXN 10000 using namespace std; int arr[MAXN]; //a bool cmp(int a,int b) { return a<b; } void Qsort(int left,int right) { if(left>=right) return 0; if(left==right-1) { if(!cmp(arr[left],arr[right])) { int t=arr[left]; arr[left]=arr[right]; arr[right]=t; } return 0; } int l=left+1,r=right; int t; while(l<r) { while(cmp(arr[left],arr[r])&&l<r) r--; while(cmp(arr[l],arr[left])&&l<r) l++; if(l<r) { t=arr[l]; arr[l]=arr[r]; arr[r]=t; } } t=arr[l]; arr[l]=arr[left]; arr[left]=t; Qsort(left,l-1); Qsort(l+1,right); return 0; }
标签:arr,right,return,int,板子,快排,cmp,left From: https://www.cnblogs.com/Sunny-John/p/18533133