?? figure4-18.cpp
字號:
#include <iostream>#include <queue>#include <functional>using namespace std;int main() { priority_queue<int> pq1; // plus vector<int> and less<int> priority_queue<int,vector<int>,greater<int> > pq2; pq1.push(3); pq1.push(1); pq1.push(2); pq2.push(3); pq2.push(1); pq2.push(2); int a[] = {4,6,5}; priority_queue<int> pq3(a,a+3); while (!pq1.empty()) { cout << pq1.top() << ' '; // 3 2 1 pq1.pop(); } while (!pq2.empty()) { cout << pq2.top() << ' '; // 1 2 3 pq2.pop(); } while (!pq3.empty()) { cout << pq3.top() << ' '; // 6 5 4 pq3.pop(); } return 0;}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -