快速排序C语言实现

快速排序C语言实现 作者: 来源:http://blog.csdn.net/cnshinhwa 发表时间:2007-04-29 浏览次数: 4804 字号:大 中 小 #include \#define LEN 8 int array[LEN] = {45,23,55,1,32,3,56,10}; void outputList() { for(int i=0;i= pivotkey) --high; array[low] = array[high]; while (low < high && array[low] <= pivotkey) ++low; array[high] = array[low]; } array[low] = tmp; return low; } void qSort(int low,int high) { if (low < high) { int pivotloc = partition(low, high); qSort(low, pivotloc - 1); qSort(pivotloc + 1, high); } } void main() { printf(\ outputList(); qSort(0,LEN-1); printf(\ outputList(); } 结果: The data before sort : 45 23 55 1 32 3 56 10 The data after sort : 1 3 10 23 32 45 55 56 Press any key to continue

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4