Name: ____________________________________________________ Alpha: _____________________
Describe help received: _________________________________________________________________
|
|
// write below the prototype of readfrom // write below the prototype of sort // write below the prototype of search
~/$ ./prog smallscoredata.txt Betty Johnson 2400 Andy Smith 800 Betty Smith 2300I have two pieces of advice. First, I would delcare a struct that represents the data in a row of the file. Second, I would sort the data first as shown below (i.e., by the last name, then the first name, then the score), and then run through the sorted data in order to pull out each individual's highest score. In fact, if you just get the sorting done right, you'll get most of the credit.
| smallscoredata.txt | sorted the "right way" |
10 Betty Smith 900 Betty Johnson 1600 Betty Johnson 2400 Andy Smith 800 Betty Smith 1200 Betty Smith 2200 Betty Johnson 1600 Andy Smith 200 Betty Smith 2300 Betty Johnson 1900 |
Betty Johnson 2400 Betty Johnson 1900 Betty Johnson 1600 Betty Johnson 1600 Andy Smith 800 Andy Smith 200 Betty Smith 2300 Betty Smith 2200 Betty Smith 1200 Betty Smith 900 |