快速排序C语言实现

更新时间:2023-09-30 08:54:01 阅读量: 综合文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

快速排序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

本文来源:https://www.bwwdw.com/article/0zfd.html

Top