c programming 68
At this point in the course we’ve studied both vectors and arrays, and have had some exposure to sort algorithms.
Write a program that reads a list of names from the provided file in this module —— and stores them into a vector of strings. The file contains randomly generated last names only.
Using one of the sort algorithms we discussed in Chapter 8 — selection sort or bubble sort, your choice — sort the vector in ascending order. No special comparisons are needed for strings, you can simply use the ‘>’ or ‘<‘ operator to compare (for example, the string “abc” will be less than (<) “def” when compared).
After sorting the vector, output the first 5 and last 5 names in the sort.
For a review of how vectors work, read Section 7.11 of the text (p. 435 – 448, with a good reference table on page 448).
Your program should output exactly the following:
First 5 names:
Last 5 names: