Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
PriQHotel
//g++ 7.4.0 ///////////////////////////////////////////////////////////////////////////// //PriQHotel: //this code is created by Rezaul Hoque on August 10,2022; 1st update: 18:33; 2nd update: 18:40; //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> using namespace std; class Hotel{ std::string star; int rent; public: Hotel(std::string s,int r); std::string getS() const; int getR() const; }; class ComS{ public: bool operator()(const Hotel & h1,const Hotel& h2) { return h1.getS()<h2.getS(); } }; class ComR{ public: bool operator()(const Hotel & h1,const Hotel& h2) { return h1.getR()<h2.getR(); } }; Hotel::Hotel(std::string s,int r) { this->star=s; this->rent=r; /*** //no need priority_queue<Hotel,vector<Hotel>,ComS> QS; priority_queue<Hotel,vector<Hotel>,ComR> QR; ***/ } std::string Hotel::getS() const { return this->star; } int Hotel:: getR() const { return this->rent; } int main() { Hotel a("***",900); Hotel b("****",3000); Hotel c("****",2500); Hotel d("**",1000); priority_queue<Hotel, vector<Hotel>,ComS> QS; QS.push(a); QS.push(b); QS.push(c); QS.push(d); std::cout<<"Hotels listed on stars:\nStars Rent\n"; while (!QS.empty()){ Hotel h=QS.top(); QS.pop(); std::cout<<h.getS()<<" "<<h.getR()<<" \n"; } std::cout<<"\n"; std::cout<<"Hotels listed on room rent:\nStars Rent\n"; priority_queue<Hotel, vector<Hotel>,ComR> QR; QR.push(a); QR.push(b); QR.push(c); QR.push(d); while (!QR.empty()){ Hotel h=QR.top(); QR.pop(); std::cout<<h.getS()<<" "<<h.getR()<<" \n"; } return 0; }
run
|
edit
|
history
|
help
0
find parent count of node in graph
Summation Of Primes
snake logic complete c++
Prosta implementacja algorytmu Euklidesa (NWD)
Gauss v0.1
cppPyFoodVatTip
Spejmer
read_write_lock_acc
RegexReplace
minmax