#include <iostream>
#include <algorithm>
#include <vector>
using std::endl;
using std::cout;
using std::vector;
struct MaxHeapCmp
{
bool operator() (const int & lhs, const int & rhs)
{
return lhs < rhs;
}
};
struct MinHeapCmp
{
bool operator() (const int & lhs, const int & rhs)
{
return lhs > rhs;
}
};
void adapt_heap
c++堆排序(STL+自实现)
最新推荐文章于 2024-07-31 17:27:42 发布
本文详细探讨了如何使用STL以及自定义方法在C++中实现堆排序算法。通过实例解析了堆排序的过程,包括建立最大堆、交换堆顶元素和调整堆等关键步骤,帮助读者深入理解堆排序的工作原理。
摘要由CSDN通过智能技术生成