Untitled document LANGUAGE: C++ 1. This will give you some experience using a few STL containers and iterators Implement the removeOdds function: #include #include #include #include #include using...

1 answer below »
in c++ please:)


Untitled document LANGUAGE: C++ 1. This will give you some experience using a few STL containers and iterators Implement the removeOdds function: #include #include #include #include #include using namespace std; // Remove the odd integers from li. // It is acceptable if the order of the remaining even integers is not // the same as in the original list. void removeOdds(list& li) { } void test1() { int a[8] = { 2, 8, 5, 6, 7, 3, 4, 1 }; list x(a, a+8); // construct x from the array assert(x.size() == 8 && x.front() == 2 && x.back() == 1); removeOdds(x); assert(x.size() == 4); vector v(x.begin(), x.end()); // construct v from x sort(v.begin(), v.end()); int expect[4] = { 2, 4, 6, 8 }; for (int k = 0; k < 4;="" k++)="" assert(v[k]="=" expect[k]);="" }="" int="" main()="" {="" test1();="" cout="">< "passed"="">< endl;="" }="" 1.="" implement="" the="" removeodds="" function:="" #include=""> #include #include #include using namespace std; // Remove the odd integers from v. // It is acceptable if the order of the remaining even integers is not // the same as in the original vector. void removeOdds(vector& v) { } void test2() { int a[8] = { 2, 8, 5, 6, 7, 3, 4, 1 }; vector x(a, a+8); // construct x from the array assert(x.size() == 8 && x.front() == 2 && x.back() == 1); removeOdds(x); assert(x.size() == 4); sort(x.begin(), x.end()); int expect[4] = { 2, 4, 6, 8 }; for (int k = 0; k < 4;="" k++)="" assert(x[k]="=" expect[k]);="" }="" int="" main()="" {="" test2();="" cout="">< "passed"="">< endl;="" }="" 2.="" implement="" the="" removebad="" function:="" #include=""> #include #include #include #include using namespace std; vector destroyedOnes3; class Movie3 { public: Movie3(int r) : m_rating(r) {} ~Movie3() { destroyedOnes3.push_back(m_rating); } int rating() const { return m_rating; } private: int m_rating; }; // Remove the movies in li with a rating below 50 and destroy them. // It is acceptable if the order of the remaining movies is not // the same as in the original list. void removeBad(list& li) { } void test3() { int a[8] = { 85, 80, 30, 70, 20, 15, 90, 10 }; list x; for (int k = 0; k < 8;="" k++)="" x.push_back(new="" movie3(a[k]));="" assert(x.size()="=" 8="" &&="" x.front()-="">rating() == 85 && x.back()->rating() == 10); removeBad(x); assert(x.size() == 4 && destroyedOnes3.size() == 4); vector v; for (list::iterator p = x.begin(); p != x.end(); p++) { Movie3* mp = *p; v.push_back(mp->rating()); } sort(v.begin(), v.end()); int expect[4] = { 70, 80, 85, 90 }; for (int k = 0; k < 4;="" k++)="" assert(v[k]="=" expect[k]);="" sort(destroyedones3.begin(),="" destroyedones3.end());="" int="" expectgone[4]="{" 10,="" 15,="" 20,="" 30="" };="" for="" (int="" k="0;" k="">< 4;="" k++)="" assert(destroyedones3[k]="=" expectgone[k]);="" }="" int="" main()="" {="" test3();="" cout="">< "passed"="">< endl;="" }="" 3.="" implement="" the="" removebad="" function:="" #include=""> #include #include #include using namespace std; vector destroyedOnes4; class Movie { public: Movie(int r) : m_rating(r) {} ~Movie() { destroyedOnes4.push_back(m_rating); } int rating() const { return m_rating; } private: int m_rating; }; // Remove the movies in v with a rating below 50 and destroy them. // It is acceptable if the order of the remaining movies is not // the same as in the original vector. void removeBad(vector& v) { } void test4() { int a[8] = { 85, 80, 30, 70, 20, 15, 90, 10 }; vector x; for (int k = 0; k < 8;="" k++)="" x.push_back(new="" movie(a[k]));="" assert(x.size()="=" 8="" &&="" x.front()-="">rating() == 85 && x.back()->rating() == 10); removeBad(x); assert(x.size() == 4 && destroyedOnes4.size() == 4); vector v; for (int k = 0; k < 4;="" k++)="" v.push_back(x[k]-="">rating()); sort(v.begin(), v.end()); int expect[4] = { 70, 80, 85, 90 }; for (int k = 0; k < 4;="" k++)="" assert(v[k]="=" expect[k]);="" sort(destroyedones4.begin(),="" destroyedones4.end());="" int="" expectgone[4]="{" 10,="" 15,="" 20,="" 30="" };="" for="" (int="" k="0;" k="">< 4;="" k++)="" assert(destroyedones4[k]="=" expectgone[k]);="" }="" int="" main()="" {="" test4();="" cout="">< "passed"="">< endl;="" }="" 4.="" 2.="" some="" word="" games,="" like="" scrabble,="" require="" rearranging="" a="" combination="" of="" letters="" to="" make="" a="" word.="" this="" type="" of="" arrangement="" is="" generally="" referred="" to="" as="" an="" anagram,="" it's="" known="" as="" a="" permutation="" in="" mathematics.write="" a="" c++="" program="" that="" searches="" for="" ``anagrams''="" in="" a="" dictionary.="" an="" anagram="" is="" a="" word="" obtained="" by="" scrambling="" the="" letters="" of="" some="" string.="" for="" example,="" the="" word="" ``pot''="" is="" an="" anagram="" of="" the="" string="" `"otp."="" a="" sample="" run="" of="" the="" program="" is="" given="" below.="" your="" output="" does="" not="" have="" to="" be="" formatted="" exactly="" the="" same="" as="" that="" shown="" in="" the="" sample,="" but="" should="" be="" in="" a="" similar="" style.="" you="" can="" use="" words.txt="" https://elcamino.instructure.com/courses/20384/files/3480731/download?download_frd="1" 3.="" download="" minimize="" file="" preview="" as="" your="" dictionary="" file.="" for="" this="" solution="" you="" must="" not="" use="" recursion.="" instead="" look="" up="" and="" use="" the="" std::next_permutation="" function="" in="" the="" algorithm="" library.="" sample="" runs="" here="" are="" two="" examples="" of="" how="" the="" program="" might="" work:="" please="" enter="" a="" string="" for="" an="" anagram:="" opt="" matching="" word="" opt="" matching="" word="" pot="" matching="" word="" top="" please="" enter="" a="" string="" for="" an="" anagram:="" blah="" 4.="" no="" matches="" found="" requirements="" you="" must="" write="" these="" two="" functions="" with="" the="" exact="" same="" function="" signature="" (include="" case):="" int="" loaddictionary(istream="" &dictfile,="">& dict); Places each string in dictfile into the vector dict. Returns the number of words loaded into dict. int permute(string word, vector& dict, vector& results); Places all the permutations of word, which are found in dict into results. Returns the number of matched words found. For words with double letters you may find that different permutations match the same word in the dictionary. For example, if you find all the permutations of the string kloo using the algorithm we've discussed you may find that the word look is found twice. The o's in kloo take turns in front. Your program should ensure that matches are unique, in other words, the results array returned from the permute function should have no dupicates. Turn it in What you will turn in for this assignment is a zip file containing these files: 1. A zip file which contains files named: --A text file named containers.cpp (this should have all the code excluding the main functions) that contains the source code for your C++ program for question 1 https://elcamino.instructure.com/courses/20384/files/3480731/download?download_frd=1 https://elcamino.instructure.com/courses/20384/assignments/462887?return_to=https%3A%2F%2Felcamino.instructure.com%2Fcalendar%23view_name%3Dmonth%26view_start%3D2021-04-27# --A text file named presumtations.cpp that contains the source code for your C++ program for question 2.
Answered 1 days AfterApr 28, 2021

Answer To: Untitled document LANGUAGE: C++ 1. This will give you some experience using a few STL containers and...

Sandeep Kumar answered on Apr 29 2021
149 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here