#include #include #include using namespace std; void Search(const vector & list, int key); int main() { vector myInts{-1,-2,-3}; size_t i; cout << "My Vector has " << myInts.size() << " integers" << endl; for(i = 0; i < myInts.size(); i++) { cout << i << " " << myInts[i] << endl; } cout << endl << endl; cout << "The last thing is " << myInts.back() << endl; cout << "The first thing is " << myInts. front() << endl; cout << endl << endl; for (auto & num : myInts) { cout << num << endl; ++num; } cout << endl << endl; for (auto num : myInts) { cout << num << endl; } cout << endl << endl; vector::iterator position; for(position = myInts.begin(); position != myInts.end(); position++) { cout << * position << endl; (*position) ++; } cout << endl << endl; vector::const_iterator cpos; for(cpos = cbegin(myInts); cpos != myInts.cend(); cpos++) { cout << *cpos << endl; ++(*cpos); } cout << endl << endl; vector::reverse_iterator rpos; for(rpos = rbegin(myInts); rpos != rend(myInts); rpos++) { cout << *rpos << endl; } cout << endl << endl; sort(rbegin(myInts), rend(myInts)); for(auto num : myInts) { cout << num << endl; } Search(myInts, 7); Search(myInts, 101); Search(myInts, 12); return 0; } void Search(const vector & list, int key){ vector::iterator pos; pos = find(list.begin(), list.end(), key); if( pos == list.end()) { cout << key << " is not in the list" << endl; } else { cout << key << " is in the list" << endl; } }