Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
UtilityPair2
//g++ 7.4.0 //////////////////////////////////////////////////////////////////////////// //UtilityPair2: understanding std::pair //this code is created by Rezaul Hoque on August 27,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 <iomanip> #include <string> #include <strstream> #include <utility> #include <vector> #include <algorithm> //stream manipulator std::ostream& l(std::ostream& os) { return (os<<"\n"); } namespace Pat { void fill(char c) { std::cout.width(40); std::cout.fill(c); std::cout<<l; } void left(int n,char c){ std::cout.setf(std::ios::left); std::cout.fill(c); std::cout.width(n); } void right(int n,char c){ std::cout.setf(std::ios::right); std::cout.fill(c); std::cout.width(n); } } int main () { Pat::fill('&'); std::vector<std::pair<std::string ,int>> n={{"zenyth",110},{"asterix",112},{"fountliv",234}}; std::vector<std::pair<std::string ,int>> a; std::swap(a,n); std::sort(a.begin (),a.end()); for (auto s:a) {std::cout<<std::get<0>(s)<<" "<<std::get<1>(s)<<l; } std::pair<std::string,std::pair<int,int>> date={"August ",{27,2022}}; std::string m; int x,y; m=date.first; std::tie(x,y)=date.second; Pat::right(25,' '); std::cout<<m<<","<<x<<" "<<y<<l; Pat::fill('&'); return 0; }
run
|
edit
|
history
|
help
0
Roots of a Quadratic Equation
Dar
sysFork3
Polyrmophism
offsetof
Tower Of Hanoi
Empty C++ Script
srednie
pangram
chocolate Distribution Problem