标签:
废话不多说,上代码:
void quicksort(int x[], int lo, int hi){ int i = lo, j = hi; int pivot = x[(lo + hi) >> 1]; while(i <= j){ while(x[i] < pivot) i++; while(x[j] > pivot) j--; if(i <= j){ swap(x[i], x[j]); i++; j--; } } if(lo < j) quicksort(lo, j); if(i < hi) quicksort(i, hi); }
Reference: here
标签:
原文地址:http://www.cnblogs.com/miaoz/p/4373571.html