I am trying to make a Gaussian distribution in visual studio C++ 2010. I want to have different results each time this is run. But when I run this code three times the result is same:
#include <iostream>
#include <random>
int roundnew(double d)
{
return floor(d + 0.5);
}
int main()
{
std::default_random_engine generator;
std::normal_distribution<double> distribution(10,1);
for (int n = 0; n < 12; ++n) {
printf("%d\n",roundnew(distribution(generator)));
}
return 0;
}
The result is
10
9
11
9
10
11
10
9
10
10
12
10
What is problem in my code? It needs seed value in my code, right? You can see the result at run code