c++ - Generating Two Random Variables Between 0 and 1 Using Same Formula -



c++ - Generating Two Random Variables Between 0 and 1 Using Same Formula -

i'm trying generate 2 different random variables between 0 , 1 @ start of main function. need 2 variables utilize in comparing different possible outcomes. however, when seek run formula twice says 'redefinition of gen' error. can please advise on how resolve error can re-use same formula , store values 2 different variables.

random_device rd; mt19937 gen(rd()); uniform_real_distribution<> dis(0, 1); auto value = dis(gen); cout << "r value " << value << endl; random_device sd; mt19937 gen(sd()); uniform_real_distribution<> dis(0, 1); auto c = dis(gen); cout << "c value " << c << endl;}

simply rename sec generator gen2 (same dis2):

random_device rd; mt19937 gen(rd()); uniform_real_distribution<> dis(0, 1); auto value = dis(gen); cout << "r value " << value << endl; random_device sd; mt19937 gen2(sd()); uniform_real_distribution<> dis2(0, 1); auto c = dis2(gen2); cout << "c value " << c << endl;}

c++

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -