Question: #include #include #include using namespace std; // Function prototypes void selectionSort(string[], int); void displayArray(string[], int); int main() { const int SIZE = 20; string name[SIZE];

#include
#include
#include
using namespace std;
// Function prototypes
void selectionSort(string[], int);
void displayArray(string[], int);
int main()
{
const int SIZE = 20;
string name[SIZE];
ifstream Read;
Read.open("names.dat");
if (!Read)
cout
else
{
for (int i = 0; i
{
getline(Read, name[i]);
}
// Call the selectionSort function
selectionSort(name, SIZE);
// Call the displayArray function
displayArray(name, SIZE);
}
Read.close();
return 0;
}
/*********************************************************************************
* selectionSort *
* This function uses the selection sort to arrange the values in a string array *
* in ascending order *
*********************************************************************************/
void selectionSort(string array[], int size)
{
int startScan, minIndex;
string minValue;
for (int startScan = 0; startScan
{
minIndex = startScan;
minValue = array[startScan];
for (int index = startScan + 1; index
{
if(array[index]
{
minValue = array[index];
minIndex = index;
}
}
array[minIndex] = array[startScan];
array[startScan] = minValue;
}
}
/*********************************************************************************
* displayArray *
* This function displays all the values in the array. *
*********************************************************************************/
void displayArray(string name[], int size)
{
for (int i = 0; i
{
cout
}

}

Copy and modify your selection sort code to use vectors (See Gaddis, Program 8-7, p. 496), then repeat Programming Challenge 8.11.

If you want information from textbook, ask in comment and I will post it .

 #include #include #include using namespace std; // Function prototypes void selectionSort(string[],

name.txt:

MARY PATRICIA LINDA BARBARA ELIZABETH JENNIFER MARIA SUSAN MARGARET DOROTHY LISA NANCY KAREN BETTY HELEN SANDRA DONNA CAROL RUTH SHARON MICHELLE LAURA SARAH KIMBERLY DEBORAH JESSICA SHIRLEY CYNTHIA ANGELA MELISSA BRENDA AMY ANNA REBECCA VIRGINIA KATHLEEN PAMELA MARTHA DEBRA AMANDA STEPHANIE CAROLYN CHRISTINE MARIE JANET CATHERINE FRANCES ANN JOYCE DIANE ALICE JULIE HEATHER TERESA DORIS GLORIA EVELYN JEAN CHERYL MILDRED KATHERINE JOAN ASHLEY JUDITH ROSE

int); void displayArray(string[], int); int main() { const int SIZE = 20;

11. Using Files-String Selection Sort Modification Modify the program you wrote for Programming Challenge 6 so it reads in 20 strings from a file. The data can be found in the names.txt file

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!