Question
C++ questions 1. Using remove_if and a custom callback function, write a function RemoveShortWords that accepts a vector and removes all strings of length 3
C++ questions
1. Using remove_if and a custom callback function, write a function RemoveShortWords that accepts a vector
This function can be written in two lines of code if you harness the algorithms correctly.
******************************************************************
Template for the main program.
vectormyList; myList.push_back("ABCDEF"); myList.push_back("ABCDE"); myList.push_back("AB"); myList.push_back("A"); myList.push_back("ABC"); myList.push_back("ABCDEFGH"); myList.push_back("ABCEDFGH"); myList.push_back("123"); myList.push_back("12"); myList.push_back("1"); myList.push_back("12345"); // Print out the vector before the sort cout << "****" << endl; removeShortWords(myList); // Print out the vector after the modify
2.
Using only the STL, Write a function BiasedSort that accepts a vector
For example, if you have a list of songs in a music library, you might want songs with the title Untitled to always appear at the top.
***************************************************
Main Program template
vectormyList; myList.push_back("Song 1"); myList.push_back("Song 5"); myList.push_back("A Song 2"); myList.push_back("Song 2"); myList.push_back("Song 3"); myList.push_back("Me First Song 3"); myList.push_back("Song 7"); myList.push_back("Song 8"); myList.push_back("Me First Song 2"); myList.push_back("Song 4"); myList.push_back("Song 6"); myList.push_back("A Song 1"); myList.push_back("Me First Song 1"); // Print out the vector before the sort cout << "****" << endl; BiasedSort(myList); // Print out the vector after the sort
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started