乱数生成

naohiro19
記事: 256
登録日時: 14年前
住所: 愛知県

乱数生成

投稿記事 by naohiro19 » 9年前

C++11に というヘッダーが使えるようになっているので 「メルサンヌツイスター法で一様乱数の1~6の乱数を生成」をしてみました。
ついでにBoostライブラリでの同じことができます。

CODE:

#include 
#include 
#include 
#include 

int main(int argc, char* argv []) {
	auto dice = std::bind(std::uniform_int_distribution(1, 6), std::mt19937(time(nullptr)));
	for (int i = 0; i 
#include 
#include 

using namespace std;

int main() {

	boost::mt19937  gen(static_cast(time(0)));
	boost::uniform_smallint dst(1, 6);
	boost::variate_generator> rand(gen, dst);

	for (int i = 0; i < 10; i++) {
		cout << rand() << endl;
	}

}
最後に編集したユーザー naohiro19 on 2016年5月01日(日) 17:25 [ 編集 1 回目 ]

コメントはまだありません。