快速排序

来源:互联网 发布:vc mfc编程实例教程 编辑:程序博客网 时间:2024/05/16 19:39
template<class T>int Partition(T Array,int low,int high){T pivot=Array[low];while (low<high){while(low<high && Array[high]>=pivot) high--;Array[low]=Array[high];while(low<high && Array[low]<=pivot)low++;Array[high]=Array[low];}Array[low]=pivot;return low;}template<class T>void QuickSort(T Array[],int low,int high){int povit_location;while (low<high){povit_location=Partition(Array,low,high);QuickSort(Array,low,povit_location-1);QuickSort(Array,povit_location+1,high);}}

原创粉丝点击