Question: Recode orange sorting example such that it uses multimaps and upper_bound(), lower_bound() functions. The example code is: #include #include #include #include #include #include using std::cin;

Recode "orange sorting" example such that it uses multimaps and upper_bound(), lower_bound() functions. The example code is:

#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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!