// High Scores // Demonstrates algorithms #include #include #include #include #include using namespace std; int main() { vector::const_iterator iter; cout << "Creating a list of scores."; vector scores; scores.push_back(1000); scores.push_back(3800); scores.push_back(9400); cout << "\nHigh Scores:\n"; for (iter = scores.begin(); iter != scores.end(); ++iter) { cout << *iter << endl; } cout << "\nFinding a score."; int score; cout << "\nEnter a score to find: "; cin >> score; iter = find(scores.begin(), scores.end(), score); if (iter != scores.end()) { cout << "Score found.\n"; } else { cout << "Score not found.\n"; } cout << "\nRandomizing scores."; srand(static_cast(time(0))); random_shuffle(scores.begin(), scores.end()); cout << "\nHigh Scores:\n"; for (iter = scores.begin(); iter != scores.end(); ++iter) { cout << *iter << endl; } cout << "\nSorting scores."; sort(scores.begin(), scores.end()); cout << "\nHigh Scores:\n"; for (iter = scores.begin(); iter != scores.end(); ++iter) { cout << *iter << endl; } return 0; }