Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions stl priority_queue.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include<iostream>
#include<queue>

using namespace std;

struct process
{
int arr_t,b_t;
};
struct CompareHeight {
bool operator()(process const& p1, process const& p2)
{
// return "true" if "p1" is ordered
// before "p2", for example:
return p1.arr_t > p2.arr_t;
}
};

int main()
{
int a;
priority_queue<process,vector<process>,CompareHeight> pq;
process p;
cout<<"enter three number::";
for(int i=0;i<3;i++)
{
cin>>p.arr_t>>p.b_t;
pq.push(p);
}
while(!pq.empty())
{
p=pq.top();
cout<<p.arr_t<<" "<<p.b_t<<endl;
pq.pop();
}
return 0;
}