#include <queue>
#include <iostream>
using namespace std;
int main()
{
priority_queue<int> pq;
//入队,插入新元素;
pq.push(1);
pq.push(2);
pq.push(3);
pq.push(9);
//返回队列中元素数目;
cout << pq.size() << endl;
//所有元素出队,删除所有元素
while (pq.empty() != true)
{
//读取当前队首元素
cout << pq.top() << " ";
//出队,删除队首元素
pq.pop();
}
cout << endl;
cin.get();
return 0;
}
#include <iostream>
using namespace std;
int main()
{
priority_queue<int> pq;
//入队,插入新元素;
pq.push(1);
pq.push(2);
pq.push(3);
pq.push(9);
//返回队列中元素数目;
cout << pq.size() << endl;
//所有元素出队,删除所有元素
while (pq.empty() != true)
{
//读取当前队首元素
cout << pq.top() << " ";
//出队,删除队首元素
pq.pop();
}
cout << endl;
cin.get();
return 0;
}