201403-1相反数

一、关于优先队列

 1 #include<iostream>
 2 #include<queue>
 3 
 4 using namespace std;
 5 
 6 priority_queue<int,vector<int>,greater<int>> q1;
 7 priority_queue<int,vector<int>,less<int>> q2;
 8 
 9 int main(){
10     for(int i=1;i<6;i++){
11         q1.push(3);
12         q1.push(5);
13         q1.push(4);
14         q1.push(10);
15         q1.push(2);
16     }
17     for(int i=1;i<6;i++){
18         q2.push(-3);
19         q2.push(-6);
20         q2.push(-5);
21         q2.push(-4);
22         q2.push(-8);
23     }
24     cout<<q1.top()<<endl;//输出2
25     cout<<q2.top()<<endl;//输出-3
26     return 0;
27 }

二、题解

 

posted @ 2022-10-10 22:13  death_gun  阅读(25)  评论(0)    收藏  举报