PrevUpHomeNext

std::mt19937 c++ 随机数生成 @cpp


c++ 随机数 std::mt19937

std::mt19937 c++ 随机数

立即使用:

#include <random>
#include <iostream>

int main()
{
	std::random_device rd;
	std::mt19937 gen{rd()};
	int x = gen();	// x 就是生成的随机数了
	std::cout << "随机数:" << x << std::endl;
}

写于

写于2025年4月7日

返回上级目录

c++ @cpp

首页:发一格 fayige.top ()

版权

Copyright 2024-2025 fayige.top

Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)


PrevUpHomeNext