Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include "testlib.h"
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. int main(int argc, char *argv[])
  7. {
  8.     if (argc < 4)
  9.     {
  10.         cout << "Command line arguments are: seed length prefix nwinners" << endl;
  11.         return 1;
  12.     }
  13.     int seed = atoi(argv[1]);
  14.     int len = atoi(argv[2]);
  15.     int prefix = atoi(argv[3]);
  16.     int nwinners = atoi(argv[4]);
  17.     rnd.setSeed(seed);
  18.  
  19.     set<int> winners;
  20.     while ((int)winners.size() < nwinners)
  21.         winners.insert(rnd.next(prefix + 1, len));
  22.  
  23.     for (int i = 1; i <= prefix; ++i)
  24.         winners.insert(i);
  25.  
  26.     for (auto winner: winners)
  27.         cout << winner << " ";
  28.     cout << endl;
  29.  
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement