1 Star 0 Fork 0

xjDing/include

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
mrandom.hpp 612 Bytes
一键复制 编辑 原始数据 按行查看 历史
xjDing 提交于 2019-05-06 20:55 +08:00 . add all files
#ifndef _MRANDOM_HPP_
#define _MRANDOM_HPP_
#include <random>
#include <functional>
class Rand_int
{
private:
std::function<int()> r;
public:
Rand_int(int lo, int hi)
: r(std::bind(std::uniform_int_distribution<>(lo, hi), std::default_random_engine{})) {}
int operator()() { return r(); }
};
class Rand_double
{
private:
std::function<double()> r;
public:
Rand_double(double lo, double hi)
: r(std::bind(std::uniform_real_distribution<>(lo, hi), std::default_random_engine{})) {}
double operator()() { return r(); }
};
using RandInt = Rand_int;
using RandDouble = Rand_double;
#endif
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/dingxuejun/include.git
git@gitee.com:dingxuejun/include.git
dingxuejun
include
include
master

搜索帮助