📄 heapsort.cpp
字号:
#include <iostream.h>
#include <stdlib.h>
#include <string.h>
#include "book.h"
#include "compare.h"
#include "maxheap.h"
template <class Elem, class Comp>
void heapsort(Elem A[], int n) { // Heapsort
Elem mval;
maxheap<Elem,Comp> H(A, n, n); // Build the heap
for (int i=0; i<n; i++) // Now sort
H.removemax(mval); // Removemax places max at end
}
template <class Elem, class Comp>
void sort(Elem* array, int n) {
heapsort<Elem,Comp>(array, n);
}
#include "sortmain.cpp"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -