Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Recode orange sorting example such that it uses multimaps and upper_bound(), lower_bound() functions. // sorting oranges // converting vectors to multimaps #include #include #include #include
Recode orange sorting example such that it uses multimaps and upper_bound(), lower_bound() functions.
// sorting oranges // converting vectors to multimaps #include#include #include #include #include #include using std::cin; using std::cout; using std::endl; using std::string; using std::vector; enum class Variety {orange, pear, apple}; vector colors = {"red", "green", "yellow"}; struct Fruit{ Variety v; string color; // red, green or orange }; int main(){ srand(time(nullptr)); vector tree(rand()%100+1); for(auto f=tree.begin(); f!=tree.end(); ++f){ f->v = static_cast (rand() % 3); f->color = colors[rand()%3]; } cout << "Colors of the oranges: "; for(auto f=tree.begin(); f!=tree.end(); ++f) if(f->v == Variety::orange) cout << f->color << ", "; cout << endl; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started