Suppose v is an object of the class
Want to see the full answer?
Check out a sample textbook solutionChapter 18 Solutions
Problem Solving with C++ (10th Edition)
Additional Engineering Textbook Solutions
Introduction To Programming Using Visual Basic (11th Edition)
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
Starting Out With Visual Basic (8th Edition)
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Starting Out with C++: Early Objects (9th Edition)
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
- In c++ please Write the RemoveEvens() function, which receives a vector of integers as a parameter and returns a new vector of integers containing only the odd numbers from the original vector. The main program outputs values of the returned vector. Hint: If the original vector has even numbers, then the new vector will be smaller in length than the original vector and should have no blank element. Ex: If the vector passed to the RemoveEvens() function is [1, 2, 3, 4, 5, 6, 7, 8, 9], then the function returns and the program output is: [1, 3, 5, 7, 9] Ex: If the vector passed to the RemoveEvens() function is [1, 9, 3], hen the function returns and the program output is: [1, 9, 3] #include <iostream>#include <vector>using namespace std; vector<int> RemoveEvens(vector<int> nums) { /* Type your code here */} int main() { vector<int> input(9); input.at(0) = 1; input.at(1) = 2; input.at(2) = 3; input.at(3) = 4; input.at(4) = 5;…arrow_forwardC++ please help I will give you a good rating!!!!! Implement the following function that returns a vector of vectors of Item, each of which is a subset of elements chosen from the given vector a[first…last]: /* if a is {1,2,3}, first=0, last=2, the function shall returns a vector of the following vectors: {}, {1}, {2}, {3}, {1,2},{1,3}, {2,3},{1,2,3}, all subsets of a[0…2]. Precondition: last-first+1>=1, i.e., there is at least one element in the a[first…last] Note 1)if the length of a[first…last] is n, then the function should return a vector of 2n vectors 2) The order of these subsets does not need to match what’s listed here… */ vector<vector<int>> subsets (const vector<int> & a, int first, int last) CODE: #include <iostream> #include <algorithm> #include <vector> using namespace std; void PrintVector (const vector<int> & v){ cout <<"["; for (auto e:v){ cout<<e<<" "; } cout <<"]"; } /*…arrow_forwardAdd a constructor initializer list to the overloaded constructor Professor(string newName, int newStudents) to initialize name with newName and students with a vector of size given by newStudents. Ex: If the input is Jan 2 Ava Ada, then the output is: Professor: Unknown, No students Professor: Jan, Students: Ava, Ada #include <iostream>#include <vector>using namespace std; class Professor {public:Professor();Professor(string newName, int newStudents);void ReadStudents();void Print() const;private:string name;vector<string> students;}; Professor::Professor() : name("Unknown"), students(0) {} Professor::Professor(string newName, int newStudents) /* Your code goes here */ {} void Professor::ReadStudents() {string studentName;int i;for (i = 0; i < students.size(); ++i) {cin >> studentName; students.at(i) = studentName;}} void Professor::Print() const {int i; cout << "Professor: " << name << ", ";if (students.size() == 0) {cout <<…arrow_forward
- Rewrite the Binary search function in the textbook to use a generic type for the array elements. Test the function with arrays of int, double, and string values. *When using test arrays make sure elements are stored in ascending sorted order*arrow_forwardCreate a generic function max that gives the maximum value of three generictype arguments that are passed to it. Then test this function by calling it with char, int,and float type.arrow_forwardCreate a function set(v, i, j) that makes vector v contain the integers i through j. The original contents of v is deleted. The vector is left empty ifj < i. The argument v is a vector of integers.arrow_forward
- Write a program that will sort a prmiitive array of data using the following guidelines - DO NOT USE VECTORS, COLLECTIONS, SETS or any other data structures from your programming language. The codes for both the money and currency should stay the same, the main focus should be on the main file code (Programming language Java) Create a helper function called 'RecurInsSort' such that: It is a standalone function not part of any class from the prior lab or any new class you feel like creating here, Takes in the same type of parameters as any standard Insertion Sort with recursion behavior, i.e. void RecurInsSort(Currency arr[], int size) Prints out how the array looks every time a recursive step returns back to its caller The objects in the array should be Money objects added or manipulated using Currency references/pointers. It is OK to print out the array partially when returning from a particular step as long as the process of sorting is clearly demonstrated in the output. In…arrow_forwardImplement the following function without using any additional data structure, and without sorting the input vectors. /* Given two vectors of integers, check if the two vectors contain same set of values: e.g., V1=[3,4,10,4,10,11] and V2=[3,3,4, 11, 10] stores same set int: {3, 4, 10, 11}. Note that duplicates are removed when considering set */ @param list1, list2: two vectors of integers@pre: list1, list2 have been initialized@post: return true if list1 and list2 stores same values (in same or different order); return false, if not. */ bool SameSet (const vector<int> & list1, const vector<int> & list2) {//for each value in list1, check if it appears in list2, if not, return false //for each value in list2, check if the value appears in list1, if not return false //return true}arrow_forwardWrite the definition for a class named Vector2D that stores information about a two-dimensional vector. The class should have functions to get and set the x and y components, where x and y are integers.Next, overload the * operator so that it returns the dot product of two vectors. The dot product of two-dimensional vectors A and B is equal to(Ax * Bx) + (Ay * By).Finally, write a main subroutine that tests the * operation.arrow_forward
- Implement a function writeEmpToFile that takes two arguments: a struct Employee pointer and a FILE *. It should write each field in order as an appropriate type. Note that you will probably want to write a length of the name before you write the characters of the name. By doing this, when you write the load function below, you can read the length of the string and use it to malloc a buffer of the proper size to hold the name. Because of the embedded name pointer, you CAN NOT write the Employee struct as a single struct. You will need to write it out field by field. You will want to write this as a binary file, not as a text file. Implement a SAVE command in your main loop that will save all the employees out to a file. The SAVE command should ask for a file name, similar to the way your FIND command asked for a name. Below is the work I have done so far that is required from the image but I have not been able to finish it and I need assistance with making the final changes that…arrow_forwardExtend the class linkedListType by adding the following operations:a. Write a function that returns the info of the kth element of the linkedlist. If no such element exists, terminate the program.b. Write a function that deletes the kth element of the linked list. If nosuch element exists, output an appropriate message. Provide the definitions of these functions in the class linkedListType. Also writea program to test these functions. (Use either the classunorderedLinkedList or the class orderedLinkedList to testyour function.) Note: Code in c++arrow_forwardWrite a template function that returns the third minimum out of all the element of an array.The arguments to the function should be the array name and the size of the array (typeint). In main(), exercise the function with arrays of type int, long, double, and char.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education