Elements read in were: 8 9 3 3 8 4 9 The number of elements is: 7 Sorted list: 3 3 4 8 8 9 9 The median is 8 Random Shuffled list: 8 8 3 9 3 9 4 The size of the list is: 7 Inserting into the list The size of the list is: 12 New list is 8 8 3 9 3 8 3 9 3 9 9 4 Size of the list after clearing it is: 0 Printing an empty list List with 3 element has size3 Elements are 20 30 6 List with 2 element has size2 Elements are 20 6 Elements are when using an iterator 20 6 // #include "stdafx.h" #include #include #include #include #include #include #include using namespace std; // begin(): Returns a random-access iterator to the first element in the container. // end(): Returns a random-access iterator that point just beyond the end of the vector. // rbegin() Returns an iterator to the first element in a reversed vector. // rend() Returns an iterator to the end of a reversed vector. // back(): Returns a reference to the last element of the vector. // front() Returns a reference to the first element in a vector. // pop_back() Deletes the element at the end of the vector. // push_back() Add an element to the end of the vector. // clear(): Erases the elements of the vector. // empty(): Tests if the vector container is empty. // erase() Removes an element or a range of elements in a vector from specified positions. // insert() Inserts an element or a number of elements into the vector at a specified position. // size() Returns the number of elements in the vector. // max_size() Returns the maximum length of the vector. // resize() Specifies a new size for a vector. // capacity(): Returns the number of elements that the vector could contain without allocating more storage. // reserve() Reserves a minimum length of storage for a vector object. // assign(): Erases a vector and copies the specified elements to the empty vector. // at(): Returns a reference to the element at a specified location in the vector. int main() { // Vectors vector hw; double *y; double x; while(cin >> x) {//Reads values till ctrl d hw.push_back(x); } cout << "Elements read in were: " << endl; for(int i=0; i::size_type size = hw.size(); if(size == 0) { cout << "The size must not be Zero" << endl; return 1; } cout << "The number of elements is: " << size << endl; cout << endl; sort(hw.begin(), hw.end()); cout << "Sorted list: " << endl; for(int i=0; i::size_type mid = size / 2; double median = (size % 2 == 0) ? (hw[mid] + hw[mid+1]) / 2 : hw[mid]; cout << "The median is " << median << endl; random_shuffle(hw.begin(), hw.end()); cout << "Random Shuffled list: " << endl; for(int i=0; i::iterator itr; for ( itr = hw.begin(); itr != hw.end(); ++itr ) cout << *itr << endl; cout << endl; }