Using
Modify the program you wrote for
Want to see the full answer?
Check out a sample textbook solutionChapter 9 Solutions
Starting Out with C++: Early Objects (9th Edition)
Additional Engineering Textbook Solutions
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Modern Database Management (12th Edition)
Starting Out with C++ from Control Structures to Objects (8th Edition)
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Artificial Intelligence: A Modern Approach
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
- C++ Help Integers are read from input and stored into a vector until 0 is read. Output the elements from index n to the last index of the vector, where n is specified by the vector's last element. End each number with a newline. Ex: If the input is 7 12 18 2 0, the vector's last element is 2. Thus, the output is: 18 2 Note: The input has at least three integers, and the vector's last element is always less than the vector's size. #include <iostream>#include <vector>using namespace std; int main() { vector<int> intVect; int value; int i; int n; cin >> value; while (value != 0) { intVect.push_back(value); cin >> value; } // insert code here return 0;}arrow_forwardA vector is an ordered list of items of different data types. Each item in a vector is called an element. Also, programmers must include the statement #include <vector> at the top of the file when planning to use vectors. true or falsearrow_forwardWord IndexWrite a python program that reads the contents of a text file. The program should create a dictionary inwhich the key-value pairs are described as follows:Key. The keys are the individual words found in the file.576Values. Each value is a list that contains the line numbers in the file where the word (thekey) is found.For example, suppose the word “robot” is found in lines 7, 18, 94, and 138. The dictionarywould contain an element in which the key was the string “robot”, and the value was a listcontaining the numbers 7, 18, 94, and 138.Once the dictionary is built, the program should create another text file, known as a word index,listing the contents of the dictionary. The word index file should contain an alphabetical listingof the words that are stored as keys in the dictionary, along with the line numbers where thewords appear in the original file. Figure 9-1 shows an example of an original text file(Kennedy.txt) and its index file (index.txtarrow_forward
- Arrays write a C++ program that will declare two static arrays where each will hold the contents of a file (random.txt) of 200 integer values. Sorting Using the two arrays, call a private member function that uses the bubble sort algorithm to sort one of the arrays in ascending order. The function should count the number of exchanges it makes. Display this value. The program should then call a private member function that uses the selection sort algorithm to sort the other array. It should also count the number of exchanges it makes. Display this value. Searching Next, call a private member function that uses the linear search program to locate the value 869. The function should keep a count of the number of comparisons it makes until it finds the value. Display this value The program then should call a private member function that uses the binary search algorithm to locate the same value. It should also keep count of the numbers of comparisons it makes. Display this…arrow_forwardUsing c++ Reverse vector Complete Reverse() function that returns a new character vector containing all contents in the input argument reversed. Ex: If the input vector is: ['a', 'b', 'c'] then the returned vector will be: ['c', 'b', 'a'] #include <algorithm>#include <iostream>#include <vector>using namespace std; int main(){ // initializing the vector vector<char> vect = { }; // Printing the vector cout<<"Reversing a vector by using reverse iterators"<<endl; cout << "Vector: "; for (int i = 0; i < vect.size(); i++) cout << vect[i]; cout << endl; //reversing the vector vector<char> v2 (vect.rbegin(),vect.rend()); vect.swap(v2); // Printing the reversed vector cout << "Reversed Vector: "; for (int i = 0; i < vect.size(); i++) cout << vect[i]; cout << endl; return 0;}arrow_forwardCode in Perl Create an array which holds a list of Video Games, consisting of title, the year it was released (guess if you don’t know) , platform (NES, XBOX One, etc) and publisher (in that order). Add at least ten albums to the list. Then, use the split function and a for or foreach loop to display the publisher followed by the title and platform for each list element.arrow_forward
- #include<bits/stdc++.h> //input of the header filesusing namespace std;set<vector<int>> s; //declaing a set to store only the unique elementsvoid solve(vector<int> input, vector<int> & output) //recursive function to generate the unique subsets{ if(input.size()==0) { vector<int> sum; //declaring a vector to store the combinations of the elements sort(output.begin(),output.end()); //sorting it to make prevent duplicates entering the set for(auto it: output) sum.push_back(it); s.insert(sum); //inserting the unique elements in the set return; //return to end the function } vector<int> out1=output; //declaring a vector to store the elements of the subset vector<int> out2=output; //declaring another vector to store the…arrow_forwardVectors Write three statements to print the first three elements of vector runTimes. Follow each with a newline. Ex: If runTime = {800, 775, 790, 805, 808}, print: 800 775 790 Note: These activities may test code with different test values. This activity will perform two tests, both with a 5-element vector. See "How to Use zyBooks".Also note: If the submitted code tries to access an invalid vector element, such as runTimes.at(9) for a 5-element vector, the test may generate strange results. Or the test may crash and report "Program end never reached", in which case the system doesn't print the test case that caused the reported message. #include <iostream>#include <vector>using namespace std; int main() {const int NUM_VALS = 5;vector<int> runTimes(NUM_VALS);unsigned int i; // Populate vectorfor (i = 0; i < runTimes.size(); ++i) {cin >> runTimes.at(i);} /* Your solution goes here */ return 0;} Please help me with this problem using c++.arrow_forward1. Loads a vector with at least 60 randomly generated integers in the range of 0 - 49. 2. Create method to display the values in the vector. 3. Use the following STL templates and display the vector contents for each template used. sort() random_shuffle() Display the result of max_element() Display the result of min_element() #include <iostream>#include <vector>#include <ctime>using namespace std; const int MAX_COUNT = 60;const int CEILING = 50; int main() { vector<int>myList;for (int idx = 0; idx < MAX_COUNT; idx++) { int myNbr = (rand() % CEILING);myList.push_back(myNbr);cout << "myNbr = " << myNbr << endl;} cout << "Size = " << myList.size() << endl;return 0;}arrow_forward
- void dict_clear (dict_t* dict); This function clears the dictionary dict, destroying each pair key/value, but does not destroy dict itself (remember that dict was allocated using dict_create, so it will need to be freed at some point, but this is not this function’s job.) This is now the function that frees (destroys) a dictionary: void dict_destroy (dict_t* dict); This operates just as dict_clear, but in addition should free the memory that was allocated during dict_create. After a call to this function, if any other library function receives the pointer dict, the behavior is undefined (most likely, it will crash). This simple function returns the current size of the dictionary: size_t dict_size (const dict_t* dict);arrow_forwardprogram9_1.pyThis assignment requires you to create a dictionary by reading the text file created for the Chapter 6 assignment. The dictionary should have player names for the keys. The value for each key must be a two-element list holding the player's goals and assists, respectively. See page 472! Start with an empty dictionary. Then, use a loop to cycle through the text file and add key-value pairs to the dictionary. Close the text file and process the dictionary to print the stats and determine the top scorer as before. In fact, much of the code used in program6_2.py can be copied and used for this program. Printing the stats for each player is the most challenging part of this program. To master this, refer to the examples in the zip file that can be downloaded from the "Dictionary values can be lists" link in the "Learn Here" part of this module. NOTE: you do not need to submit the text file. Submit just this program. The required output should be the same well-formatted table as…arrow_forwardprogram9_1.pyThis assignment requires you to create a dictionary by reading the text file created for the Chapter 6 assignment. The dictionary should have player names for the keys. The value for each key must be a two-element list holding the player's goals and assists, respectively. See page 472! Start with an empty dictionary. Then, use a loop to cycle through the text file and add key-value pairs to the dictionary. Close the text file and process the dictionary to print the stats and determine the top scorer as before. In fact, much of the code used in program6_2.py can be copied and used for this program. Printing the stats for each player is the most challenging part of this program. To master this, refer to the examples in the zip file that can be downloaded from the "Dictionary values can be lists" link in the "Learn Here" part of this module. NOTE: you do not need to submit the text file. Submit just this program. The required output should be the same well-formatted table as…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