Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
PriorQ2
//g++ 7.4.0 ////////////////////////////////////////////////////////////////////////////// //PriorQ2 //operator() overloading credit goes to geeksfor geeks.com;rest of the code is created by Rezaul Hoque on July 08,2022; //contact:jewelmrh@yahoo.com;Dhaka,Bangladesh;https://rezaulhoque.wordpress.com,https://hoquestake.blogspot.com //note: codes shared by Rezaul Hoque on rextester are not for sale; they are created and shared to facilitate the algorithm learning process; many like Hoque use this platform to practice programming ;Rezaul hopes his contribution helps others to fine tune their learning; ///////////////////////////////////////////////////////////////////////////// #include <iostream> #include <queue> #include <string> #include <vector> class DePQ{ std::string city; public: int rank; DePQ(){} DePQ(std::string s,int r){city =s; rank=r;} DePQ(const DePQ& c){ city=c.city; rank=c.rank;} ~DePQ(){} std::string getC(){return city;} int getR(){return rank;} }; bool operator<(const DePQ& q1,const DePQ& q2) { return q1.rank<q2.rank; } int main() { std::priority_queue<DePQ> p; p.push(DePQ("Rome",2)); p.push(DePQ("Sparta ",1)); p.push(DePQ("Athens", 3)); while (p.empty()==false) { DePQ q=p.top(); p.pop(); std::cout<<q.getC()<<" "<<q.getR()<<"\n"; } return 0; }
run
|
edit
|
history
|
help
0
sdfg
Test 12(2021)
Stream8
Dar
5345
decode
TREE - path from root to leaf with given sum
march long ques 4
Binary Tree
Random Vector Generator