Starting Out with C++: Early Objects (9th Edition)
Starting Out with C++: Early Objects (9th Edition)
9th Edition
ISBN: 9780134400242
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: PEARSON
bartleby

Videos

Textbook Question
Book Icon
Chapter 9, Problem 16PC

Using Vectors — String Selection Sort Modification

Modify the program you wrote for Programming Challenge 15 so it stores the names in a vector of strings, rather than in an array of strings. Create the vector without specifying a size and then use the push_back member function to add an element holding each string to the vector as it is read in from a file. Instead of assuming there are always 20 strings, read in the strings and add them to the vector until there is no data left in the file. The data can be found in the names. dat file.

Blurred answer
Students have asked these similar questions
EmpFromFile     Implement a function readEmpFromFile that takes a FILE * as the only argument and returns a pointer to a struct employee. This function should read the information from the file (reversing what writeEmpToFile does), create a new employee and fill in the data. If the FILE has no more info (is at end of file), this function should return NULL. This function must also ensure any employee actually created (not the NULL) is added to the array (as is done in createEmployee). Change main to load employees from a file using a command called LOAD which is given to the program using (using your readEmpFromFile function you just wrote).   void main(void) {     int end = 1;     char * command;     char buff[256];     char * findEmp;     char findBuff[256];     char * sortType;     char sortBuff[256];     char hire[] = "HIRE";     char list[] = "LIST";     char quit[] = "QUIT";     char find[] = "FIND";     char fire[] = "FIRE";     char _sort[] = "SORT";     char salary[] =…
Finish the code algorthims #include <iostream> #include <vector> using namespace std; //Todo4: Add cout statement to MergeSort () to print out // a line for each time this function is called, show the parameter // a line for each time we return from this function, show the parameter //Todo3: add a global variable to keep track // frequency of copy operation (marked below), and comparison operation (marked below) // /* Merge two sorted vectors' elements into one sorted vector @param l1, l2: two sorted vectors @param list: the vector to hold the merging result @pre-condcition: elements in l1, l2 are in ascending order @post-condcition: list contains elements from l1 and l2, in ascending order */ void BinaryMergeSortedList (const vector<int> l1, const vector<int> l2, vector<int> & list) { //Idea: as well as l1 and l2 both have elements left to be copied to list, // compare the "front runner", and copy the smaller one to next slot in list. // When only one…
C++  Sort a vector Define a function named SortVector that takes a vector of integers as a parameter. Function SortVector() modifies the vector parameter by sorting the elements in descending order (highest to lowest). Then write a main program that reads a list of integers from input, stores the integers in a vector, calls SortVector(), and outputs the sorted vector. The first input integer indicates how many numbers are in the list. Ex: If the input is: 5 10 4 39 12 2 the output is: 39,12,10,4,2, For coding simplicity, follow every output value by a comma, including the last one. Your program must define and call the following function:void SortVector(vector<int>& myVec)     #include <iostream>#include <vector>using namespace std; /* Define your function here */ int main() {   /* Type your code here */    return 0;}   Enter program input - 5 10 4 39 12 2

Chapter 9 Solutions

Starting Out with C++: Early Objects (9th Edition)

Ch. 9.6 - Prob. 9.11CPCh. 9.6 - Prob. 9.12CPCh. 9.6 - Prob. 9.13CPCh. 9.6 - Prob. 9.14CPCh. 9.6 - Prob. 9.15CPCh. 9 - Prob. 1RQECh. 9 - Prob. 2RQECh. 9 - Prob. 3RQECh. 9 - Prob. 4RQECh. 9 - Prob. 5RQECh. 9 - Prob. 6RQECh. 9 - Prob. 7RQECh. 9 - A binary search will find the value it is looking...Ch. 9 - The maximum number of comparisons that a binary...Ch. 9 - Prob. 11RQECh. 9 - Prob. 12RQECh. 9 - Bubble sort places ______ number(s) in place on...Ch. 9 - Selection sort places ______ number(s) in place on...Ch. 9 - Prob. 15RQECh. 9 - Prob. 16RQECh. 9 - Why is selection sort more efficient than bubble...Ch. 9 - Prob. 18RQECh. 9 - Prob. 19RQECh. 9 - Prob. 20RQECh. 9 - Prob. 21RQECh. 9 - Charge Account Validation Write a program that...Ch. 9 - Lottery Winners A lottery ticket buyer purchases...Ch. 9 - Lottery Winners Modification Modify the program...Ch. 9 - Batting Averages Write a program that creates and...Ch. 9 - Hit the Slopes Write a program that can be used by...Ch. 9 - String Selection Sort Modify the selectionSort...Ch. 9 - Binary String Search Modify the binarySearch...Ch. 9 - Search Benchmarks Write a program that has at...Ch. 9 - Sorting Benchmarks Write a program that uses two...Ch. 9 - Sorting Orders Write a program that uses two...Ch. 9 - Ascending Circles Program 8-31 from Chapter 8...Ch. 9 - Modified Bin Manager Class Modify the BinManager...Ch. 9 - Using Files-Birthday List Write a program that...Ch. 9 - Prob. 14PCCh. 9 - Using Files-String Selection Sort Modification...Ch. 9 - Using Vectors String Selection Sort Modification...

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
1.1 Arrays in Data Structure | Declaration, Initialization, Memory representation; Author: Jenny's lectures CS/IT NET&JRF;https://www.youtube.com/watch?v=AT14lCXuMKI;License: Standard YouTube License, CC-BY
Definition of Array; Author: Neso Academy;https://www.youtube.com/watch?v=55l-aZ7_F24;License: Standard Youtube License