Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
DailyExchRate2
//g++ 7.4.0 ////////////////////////////////////////////////////////////////////////////////DailyExchRate2: example of enumeration with overloaded operator using class //this code is created by Rezaul Hoque on May 20,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 <string> enum Day {Sat,Sun,Mon,Tue,Wed,Thu,Fri}; enum Exch {Taka, Eur,Inr,Pound,Yen,Ruble,Yuan}; //enumeration with overloaded operator std::ostream& operator<<(std::ostream& outs, Day j) { switch(j){ case Sat: outs<<"Saturday"; break; case Sun: outs<<"Sunday"; break; case Mon: outs<<"Monday"; break; case Tue: outs<<"Tuesday"; break; case Wed: outs<<"Wednesday"; break; case Thu: outs<<"Thursday"; break; case Fri: outs<<"Friday"; break; } return outs; } std::ostream& operator<<(std::ostream& outs, Exch cr) { switch(cr){ case Taka: outs<<"88.0 Taka"; break; case Eur: outs<<"0.95 Euro"; break; case Inr: outs<<"77.50 Indian Rupee"; break; case Pound: outs<<"0.81 Pound"; break; case Yen: outs<<"128.82 Yen"; break; case Ruble: outs<<" 63.40 Ruble"; break; case Yuan: outs<<"6.76 Yuan"; break; } return outs; } class CutRate{ Day day; Exch currency; std::string country; std::string city; public: CutRate(){} CutRate(Day j,std::string c,std::string v,Exch m){ day=j;country=c;city=v;currency=m;} CutRate(CutRate& s){ day=s.day;country=s.country;city=s.city;currency=s.currency;} ~CutRate(){} Day getDay(){return day;} std::string getCountry(){return country;} std::string getCity(){return city;} Exch getCur(){return currency;} }; int main() { CutRate c(Thu,"Bangladesh","Dhaka",Yuan); std::cout<<"Day Country City Exch.Rate($1)\n"; { std::cout<<c.getDay()<<" "; std::cout<<c.getCountry()<<" "; std::cout<<c.getCity()<<" "; std::cout<<c.getCur()<<" "; std::cout<<"\n"; } return 0; }
run
|
edit
|
history
|
help
0
Radix sort
congruence modulo equations (together with a simple BigInteger class)
cppPyFoodVatTip
DSU on tree (http://codeforces.com/contest/600/problem/E)
N Qeens problem
1
PhoneDirectory
Boggle Game
FindMissingLagrange
Wave Sort