#include<iostream>
#include <queue>
using namespace std;
int main()
{
priority_queue<int> a;//a为最大值优先队列
priority_queue<int, vector<int>, greater<int> > c; //c为最小值优先队列
priority_queue<string> b;//b为最大值优先队列
for (int i = 0; i < 5; i++)
{
int t;
cin >> t;
a.push(t);
c.push(t);
}
while (!a.empty())
{
cout << a.top() << ' ';
a.pop();
}
cout << endl;
while (!c.empty())
{
cout << c.top() << ' ';
c.pop();
}
cout << endl;
return 0;
}
最大值优先队列和最小值优先队列
最新推荐文章于 2024-05-10 16:46:34 发布