G
Gary Wessle
Hi
using The Boost Random Number Library. how can I get a random number
every time I run the project "./proj"
the code below prints out 10 random numbers but it will print the same
exact numbers every time it runs. I just need one number not 10, and
random "different from the one before".
I can do the first "remove the for loop" but not able to do the
second.
#include <boost/random.hpp>
typedef boost::minstd_rand base_generator_type;
int main(){
base_generator_type generator(42u);
boost::uniform_real<> uni_dist(0,1);
boost::variate_generator<base_generator_type&, boost::uniform_real<> > uni(generator, uni_dist);
for(int i=0; i<10; i++)
std::cout << uni() << std::endl;
}
thanks
using The Boost Random Number Library. how can I get a random number
every time I run the project "./proj"
the code below prints out 10 random numbers but it will print the same
exact numbers every time it runs. I just need one number not 10, and
random "different from the one before".
I can do the first "remove the for loop" but not able to do the
second.
#include <boost/random.hpp>
typedef boost::minstd_rand base_generator_type;
int main(){
base_generator_type generator(42u);
boost::uniform_real<> uni_dist(0,1);
boost::variate_generator<base_generator_type&, boost::uniform_real<> > uni(generator, uni_dist);
for(int i=0; i<10; i++)
std::cout << uni() << std::endl;
}
thanks