// using find() and sort() to modify vector // Mikhail Nesterenko // 4/15/2019 #include #include #include using std::cin; using std::cout; using std:: endl; using std::vector; int main(){ vector v; // inputing the numbers cout << "Enter numbers, 0 to quit: "; int num; cin >> num; while(num!=0){ vector::iterator ip=v.end(); v.insert(ip,num); cin >> num; } cout << "Enter number to remove: "; int numToRemove; cin >> numToRemove; // using find() to locate number vector::iterator it; it = find(v.begin(), v.end(), numToRemove); if (it != v.end()){ // if found, erase cout << "found number at location " << it - v.begin() << endl; v.erase(it); } sort(v.begin(),v.end()); // sorting elements // printing the sorted numbers cout << "Your numbers sorted: "; for(vector::iterator ip=v.begin(); ip != v.end(); ++ip) cout << *ip << " "; cout << endl; }