CS 202 Fall 2013  >  In-Class Challenge for Tuesday, November 12, 2013

CS 202 Fall 2013
In-Class Challenge for Tuesday, November 12, 2013

Our Goal

We wish to write a program that keeps track of a dataset in a vector and applies various algorithmic modifications to it.

What to Do

  1. Write a program algomod.cpp that keeps track of a vector<int> of size 20. The program initializes the data to a collection of 20 random numbers, each in the range 0 .. 12, and then repeatedly does the following:
    • Print the dataset.
    • Present the user with a menu of modifications to apply. These must include:
      • Re-initializing the data set to 20 values, each 0 .. 12.
      • Randomly re-ordering the values in the dataset.
      • Reversing the order of the values in the dataset.
      • Sorting the dataset in increasing order.
      • Setting every value in the dataset to 6.
      • Calling Standard Library function unique, passing the results of the begin and end member functions of the vector.
      • Exit.
    • Get the user’s choice. If the user chose to exit, then do so; otherwise, continue.
    • Perform the requested operation.

    Except for the re-inizialize option, each algorithmic modification must be performed using a single function call to a C++ Standard Library function.

Other Stuff


CS 202 Fall 2013: In-Class Challenge for Tuesday, November 12, 2013 / Updated: 12 Nov 2013 / Glenn G. Chappell