Question: C++ STL Containers, Iterators and Algorithms #include using std::cout; using std::endl; int main(){ cout < < ---------------------- STL vector ---------------------- ; // declare container here
C++ STL Containers,Iterators and Algorithms #includeusing std::cout; using std::endl; int main(){ cout << "---------------------- STL vector ---------------------- "; // declare container here cout << "Enter numbers to store in STL containers (enter a letter to stop) "; // read in integers from STDIN here and store them in the vector cout << "There are " << << " integers in the vector" << endl; // print out the contents of the container in the reverse order that they were read in cout << "---------------------- STL list ---------------------- "; // declare container here // copy elements from the vector into this container (in the order that they were entered) cout << "There are " << << " integers in the list" << endl; // print out the contents of the container in the reverse order that they were read in // Hint: Make a copy of the elements into a second list first . . . cout << "---------------------- STL deque ---------------------- "; // declare container here // copy elements from the vector into this container (in the order that they were entered) cout << "There are " << << " integers in the deque" << endl; // print out the contents of the container in the reverse order that they were read in cout << "---------------------- STL stack ---------------------- "; // declare container here // Optionally, for a challenge, specify the underlying container (and it's type) when declaring the stack container (and it's type) // copy elements from the vector into this container (in the order that they were entered) cout << "There are " << << " integers in the stack" << endl; // print out the contents of the container in the reverse order that they were read in cout << "---------------------- STL queue ---------------------- "; // declare container here // copy elements from the vector into this container (in the order that they were entered) cout << "There are " << << " integers in the queue" << endl; // print out the contents of the container in the reverse order that they were read in // Hint: For each element, make a temporary queue with all of the remaining elements in it . . . cout << "---------------------- STL priority_queue ---------------------- "; // declare container here // copy elements from the vector into this container (in the order that they were entered) cout << "There are " << << " integers in the priority_queue" << endl; cout << "Priority queues do not keep track of the insertion order of their contents, but here's it's contents: "; // print out the contents of the container cout << " Can the number of elements and the contents be printed out in the order that they were entered for associative containers? Why? "; /* * Answer the question here with a cout statement */ /* * lab17B */ cout << " ---------------------- Printing out the contents in the ordered entered using iterators ---------------------- "; cout << "---------------------- STL vector ---------------------- "; // use STL vector iterators to print out the values stored in the container if possible (otherwise print out why it's not possible) cout << "---------------------- STL array ---------------------- "; // use STL array iterators to print out the values stored in the container if possible (otherwise print out why it's not possible) cout << "---------------------- STL list ---------------------- "; // use STL list iterators to print out the values stored in the container if possible (otherwise print out why it's not possible) cout << "---------------------- STL forward_list ---------------------- "; // use STL forward_list iterators to print out the values stored in the container if possible (otherwise print out why it's not possible) cout << "---------------------- STL deque ---------------------- "; // use STL deque iterators to print out the values stored in the container if possible (otherwise print out why it's not possible) cout << "---------------------- STL stack ---------------------- "; // use STL stack iterators to print out the values stored in the container if possible (otherwise print out why it's not possible) cout << "---------------------- STL queue ---------------------- "; // use STL queue iterators to print out the values stored in the container if possible (otherwise print out why it's not possible) cout << "---------------------- STL priority_queue ---------------------- "; // use STL priority_queue iterators to print out the values stored in the container if possible (otherwise print out why it's not possible) cout << " ---------------------- Determine the unique elements in the vector (using STL algorithms) and print them out ---------------------- "; // determine the unique elements in the vector (using STL algorithms) // Hint: You'll need to use a couple of different functions cout << "There are a total of " << << " unique integers: "; // print out the unique elements return 0; }
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
