不要让昨天 占据你的今天 夏午晴天

夏午晴天

优先队列

 1 #include <iostream>
 2 #include <queue>
 3 #include <vector>
 4 using namespace std;
 5 
 6 struct cmp
 7 {
 8     bool operator()( const int &a, const int &b )
 9     {
10         return a < b;
11     }
12 };
13 
14 int main()
15 {
16     //priority_queue< int, vector<int>, greater<int> > q;
17     //priority_queue<int> q;
18     //priority_queue< int, vector<int>, less<int> > q;
19     priority_queue< int, vector<int>, cmp > q;
20     int n;
21     cin >> n;
22     while(n--)
23     {
24         int cmp;
25         cin >> cmp;
26         q.push(cmp);
27     }
28     while(!q.empty())
29     {
30         cout << q.top() << endl;
31         q.pop();
32     }
33     return 0;
34 }
35 //4006

 

posted on 2017-03-08 21:09  夏晴天  阅读(91)  评论(0编辑  收藏  举报

导航

Live2D