1 #include<bits/stdc++.h> 2 using namespace std; 3 priority_queue<int>q; //从大到小 4 priority_queue<int,vector<int>,greater<int> >Q; //从小到大 5 //结构体元素类型: 6 struct node 7 { 8 int x,y,z; 9 friend bool operator <(const node &a,const node &b){ 10 return a.x>b.x;//(小顶) 11 //(return a.x<b.x;大顶) 12 } 13 }; 14 priority_queue<node>QQ; 15 int main() 16 { 17 for(int i=1;i<=5;i++){ 18 int tmp; 19 scanf("%d",&tmp); 20 q.push(tmp); 21 Q.push(tmp); 22 } 23 while(!q.empty()){ 24 25 printf("%d ",q.top()); 26 q.pop(); 27 } 28 printf("\n"); 29 while(!Q.empty()){ 30 printf("%d ",Q.top()); 31 Q.pop(); 32 } 33 printf("\n"); 34 return 0; 35 }