排序
int partition(int a[], int low, int high){ int key = a[low]; while( low < high ){ while(low < high && a[high] >= key) high--; a[low] = a[high]; while(low < high && a[low] <= key) low++; a[high] = a[low]; } a[low] = key; return low; } void quick_sort(int a[], int low, int high){ if(low >= high) return; int keypos = partition(a, low, high); quick_sort(a, low, keypos-1); quick_sort(a, keypos+1, high); }
Last updated