boost::randomで乱数生成
- http://www.kmonos.net/alang/boost/classes/random.html
- http://d.hatena.ne.jp/rigarash/20090629/1246269937
#include <iostream> #include <ctime> #include <boost/random.hpp> using namespace std; using namespace boost; int main(void) { mt19937 gen(static_cast<unsigned long>(time(0))); uniform_smallint<> dst(1, 100); // 1~100の乱数 uniform_realでdouble型になる variate_generator<mt19937, uniform_smallint<> > rand( gen, dst ); for (int i = 0; i < 10; i++) { cout << rand() << endl; } return 0; }