📄 heapsort.cpp
字号:
#include "MinHeap.h"
#include "datatype.h"
void HeapSort(datatype a[], int n)
{
MinHeap<datatype> H1(a, n); //堆化数组a
datatype temp;
for(int i = n-1; i > 0; i--)
{
temp = H1.Delete();
a[i] = temp;
}
}
void main(void)
{
datatype test[] = {64,5,7,89,6,24};
int n = 6;
HeapSort(test,n);
for(int i = 0; i < n; i++)
cout << test[i].key << " ";
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -