priority_queue.cpp
来自「Vc.Net入门与提高源码」· C++ 代码 · 共 44 行
CPP
44 行
// compile with: /EHsc
#include <iostream>
#include <queue>
#include <deque>
#include <vector>
#include <functional>
using namespace std ;
typedef deque<int> INTDQU;
typedef priority_queue<int> INTPRQUE;
typedef vector<char> CHVECTOR;
typedef priority_queue<char> CHPRQUE;
int main(void)
{
size_t size_q;
INTPRQUE q;
CHPRQUE p;
// Insert items in the priority_queue(uses deque)
q.push(42);
q.push(100);
q.push(49);
q.push(201);
cout << q.top() << endl;
size_q = q.size();
cout << "size of q is:" << size_q << endl;
while (!q.empty())
{
cout << q.top() << endl;
q.pop();
}
p.push('c');
p.push('a');
p.push('d');
p.push('m');
p.push('h');
cout << p.top() << endl;
size_q = p.size();
cout << "size of p is:" << size_q << endl;
while (!p.empty())
{
cout << p.top() << endl;
p.pop();
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?