#include <iostream> #include <queue> #include <vector> #include <stdio.h> using namespace std; struct p{ int x,y,t; bool operator < (const p &a)const { return t>a.t;//取时间最少优先 } }Point; int main(){ priority_queue<p> q; for( int i = 1; i <= 5; i++ ){ Point.x = i; Point.y = i; Point.t = i; q.push(Point); } while( !q.empty() ){ cout << q.top().t << endl; q.pop(); } } #include <iostream> #include <queue> using namespace std; struct cmp{ bool operator < (int &a,int &b){ return a < b; } } int main(){ queue<int,vector<int>,cmp> q; }
时间: 2024-12-09 21:23:58