Sorting Program:
Have a data file that contains TV shows, and the network that they air
on.
Such as "Lost" is on "ABC".
Store this in a plain text file (notepad) in the following format.
Show;Network
Lost;ABC
The semicolon ; is used to separate the data values.
I am taking the liberty in assuming that there are no show titles that
contain ; in them.
Write the show and network information one show per line.
Make a file with 10 shows (with mixed networks).
Your program will read these strings in, one line at a time. You will
have 2 arrays, to hold 10 elements each. One array for the show titles,
and the other for the show networks.
For example:
show[0]="American Idol";
network[0]="FOX";
However, you will be reading these values in from a file, not writing
the values in C++. The above instructions, are just for an example.
When you sort the data, you must remember to move both the show title
and the network to the correct index.
You will need to use a temporary value when swapping positions.
Your program will display the data 2 ways with the heading for each:
- Sorted by show title.
- Sorted by network (with a subsort of the show titles).
Examples:
Sorted by Show
Show
Network
American Idol
FOX
Dancing with the Stars FOX
Lost
ABC
Sorted by Network
Network
Show
ABC
Lost
FOX
American Idol
FOX
Dancing with the
Stars
To sort by network: when sorting, test
the network name AND the show
title to see which is greater.
Use comments & functions to help
make your code easier to read.