![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
排序算法
文章平均质量分 66
常规的排序算法
玖十三
大学生
展开
-
原始的归并排序代码实现cpp
原始的归并排序template <class Type>void Merge(Type a[],Type t[],int l,int mid,int r){ int i = l,j = mid+1; int k = 0; while(i<=mid&&j<=r){ if(a[i]<=a[j]){ t[k++]=a[i++]; } else {原创 2020-12-03 15:31:45 · 89 阅读 · 0 评论 -
堆排序的代码实现(大根堆\小根堆)cpp
堆排序#define LT(a,b) ((a) < (b))//大根堆 顺序#define RT(a,b) ((a) > (b))//小根堆 逆序template<class Type>void HeapAdjust(Type a[],int s,int m){//调整堆 Type rc = a[s];//顶端a[s] for(int i=2*s;i<=m;i*=2){ if(RT(a[i],a[i+1])&&i<m原创 2020-12-03 15:28:40 · 247 阅读 · 0 评论 -
希尔排序的代码实现cpp
希尔排序template <class Type>void InsertSort(Type a[],int n,int d){//插入排序 for(int i=d;i<n;++i){ for(int j=i-d;j>=0;--j){ if(a[j]>a[j+d]){ swap(a[j],a[j+d]); } } }}template <c原创 2020-12-03 15:30:44 · 78 阅读 · 0 评论