Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
SetHotel
//g++ 7.4.0 ///////////////////////////////////////////////////////////////////////////// //SetHotel //this code is created by Rezaul Hoque on August 11,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 <set> using namespace std; class Hotel{ set<std::string> star; int rent; public: Hotel(set<std::string> s,int r); set<std::string> getS(); int getR() ; }; Hotel::Hotel(set<std::string> s,int r) { this->star=s; this->rent=r; } set<std::string> Hotel::getS() { return this->star; } int Hotel:: getR() { return this->rent; } int main() { set<std::string>s1,s2,s3,s4; s1.insert("***"); s2.insert("****"); s3.insert("**"); s4.insert("***"); Hotel a(s1,900); Hotel b(s2,3000); Hotel c(s3,2500); Hotel d(s4,1000); priority_queue<set<std::string>,vector<set<std::string>>,greater<set<std::string>>> QS; QS.push(a.getS()); QS.push(b.getS()); QS.push(c.getS()); QS.push(d.getS()); std::cout<<"Hotels listed on stars:\nStars\n"; while (!QS.empty()){ set<std::string> h=QS.top(); QS.pop(); for(auto p:h){ std::cout<<p<<" "<<" \n";} } return 0; }
run
|
edit
|
history
|
help
0
container store pointer
Stream10
543
pbds
Exempel 2
test
Test 12(2021)
Interview Prep
HotelVec
O