优先级队列-堆-STL实现
2024-09-01 09:35:25
#include <cstdio>
#include <iostream>
#include <queue> using namespace std; // 默认是最大堆
// int main()
{
priority_queue<int> heap;
heap.push();
heap.push();
heap.push();
heap.push(); while(!heap.empty())
{
cout<<heap.top()<<endl;
heap.pop();
} // 如何实现最小堆?
priority_queue<int,vector<int>,greater<int>> heap2;
heap2.push();
heap2.push();
heap2.push();
heap2.push();
heap2.push(); while(!heap2.empty())
{
cout<<heap2.top()<<endl;
heap2.pop();
}
return ;
}
最新文章
- September 29th 2016 Week 40th Thursday
- SQL Server 利用批量(batchsize)提交加快数据生成/导入
- maven问题-";resolution will not be reattempted until the update interval of MyRepo has elapsed";
- 【BZOJ】3319: 黑白树
- 9.DataPager
- Mac Please try running this command again as root/Administrator.
- scala map
- iOS 开发之动画篇 - 从 UIView 动画说起
- docker核心概念及centos6下安装
- Python_csv电子表格
- AI数据分析(三)
- 9、Docker私有registry
- Treiber Stack介绍
- 快速可靠网络传输协议 KCP(转)
- ADO.net方法
- jQuery中通过$.browser来判断浏览器
- 牛客OI赛制测试赛1 题解
- Mac下常用按键符号⌘(command)、⌥(option)、⇧(shift)、⇪(caps lock)、⌃(control)、↩(return)、⌅(enter)
- C语言中赋值表达式的返回值是什么?
- 前端基础HTML
热门文章
- Dubbo学习系列之十七(微服务Soul网关)
- 【搞定面试官】- Synchronized如何实现同步?锁优化?(1)
- 用例建模Use Case Modeling——传感器智能分析引擎
- Mongodb 3.2.8: 集群环境搭建
- Android View的绘制机制前世今生---前世
- 1282 - Leading and Trailing 求n^k的前三位和后三位。
- MySQL热机双备之双主同步复制配置
- 进阶之路 | 奇妙的Drawable之旅
- vscode+php+xdebug Time-out connecting to client (Waited: 200 ms)
- opencv —— convexHull 寻找并绘制凸包