mardi 9 février 2016

std::default_random_engine gives the same result for different seeds

I expect to receive different outputs, but I am getting two zeros independent of the seed value (here used 1 nad 2):

#include <iostream>
#include <string>
#include <random>

using namespace std;

int main()
{
  default_random_engine e1(1);
  default_random_engine e2(2);

  uniform_int_distribution<int> chose(0, 50);

  int a1 = chose(e1); cout << a1 << endl;
  int a2 = chose(e2); cout << a2 << endl;
}

What is wrong with my code?




Aucun commentaire:

Enregistrer un commentaire