Course Web Pages

Related Links

Free eBooks

Iterators and Algorithms

Beginning C++ Through Game Programming, by Michael Dawson.

Hero's Inventory 3.0, Part 1


Hero's Inventory 3.0, Part 2

High Scores


Download max_score.cpp. This program takes a set of scores and finds the highest one. Modify the file as follows:

  1. Instead of hard coding three scores in the code, read scores from this scores.txt file.
  2. Iterate through the scores with an iterator instead of using the index (int i) into the vector.
  3. Bonus exercise

    Do a web search to see if you can find an algorithm that locates the maximum element in a vector. Use this algorithm to write a shorter version of max_score.cpp. Name it max_score2.cpp. Note: this exercise is in addition to the previous exercises. It is not a replacement for either of them.