
排序算法
CTO_TOC
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
堆排序_Heap Sort
PS:使用模板函数进行编程子函数的编写template<class T> void heap_sort(T*array,int length) { int i; buildMaxHeap(array,length-1); for(i=(length-1);i>=1;i--) { swap(&array[0],&array[i]); he原创 2017-06-08 21:09:14 · 220 阅读 · 0 评论 -
直接插入排序
//直接插入排序 template void insert_sort(T*s ,int n) { int i,j; T temp; for(i = 1;i<n;i++) { temp = s[i]; for(j=i-1;j>=0&&temp<s[j];j--) { s[j+1] = s[j]; } } s[j+1] = tem原创 2017-09-02 21:34:12 · 187 阅读 · 0 评论 -
希尔排序_Shell Sort
template void shell_sort(T*s,int n) { T temp; int i,j,h; for( h=n/2;h>0;h=h/2) { for( i=h;i<n;i++) { temp = s[i]; for(j=i-h;j>=0&&temp<s[j];j=j-h) { s[j+h]=s[j]; } s[j+h] =原创 2017-09-02 21:41:30 · 238 阅读 · 0 评论