task2pre.cpp

URL: https://mirkwood.cs.edinboro.edu/~bennett/class/cmsc2040/fall2026/notes/dice/code/task2pre.cpp
 
#include <iostream>
#include <iomanip>

using namespace std;

void RollDieAndPrint(unsigned int seedA, unsigned int seedB);

int main() {

   //srand(static_cast<int>(time(nullptr)));
   unsigned int seed1{static_cast<unsigned int>(rand())}, 
                seed2{static_cast<unsigned int>(rand())};

   cout << "Die 1 then  Die 2" << endl;
   RollDieAndPrint(seed1, seed2);
   cout << endl;
   cout << "Die 2 then Die 1" << endl;
   RollDieAndPrint(seed2, seed1);

   return 0;
}


void RollDieAndPrint(unsigned int seedA, unsigned int seedB) {
   int die1, die2;

   for(int i = 0; i < 10; ++i) {
      die1 = rand_r(&seedA) % 6  + 1;
      die2 = rand_r(&seedB) % 6  + 1;
      cout << setw(20) << die1 << setw(20) << die2 << endl;
   }
}