11.11. Mixed-Up Code Exercises

Answer the following Mixed-Up Code questions to assess what you have learned in this chapter.

Q1

Suppose you run Club Keno, and you are in charge of picking the 20 random numbered balls between 1 and 80. Construct a block of code that chooses these random numbers, then saves them to a vector called <code>keno</code>.

  1. for (int i = 0; i < 20; ++i) {
  2. for (int i = 0; i <= 20; ++i) { #distractor
  3. int x = std::uniform_int_distribution<int> {0, 80} (eng); #distractor
  4. int x = std::uniform_int_distribution<int> {1, 81} (eng);
  5. keno.push_back(i); #distractor
  6. keno.push_back(x);
  7. std::default_random_engine eng(device());
  8. std::random_device device;
  9. std::vector<int> keno;
  10. }