User Tools

Site Tools


c:c_random_numbers

C - C++ Random Numbers

random_number.hpp

#pragma once
 
#include <random>
 
int random_int_number(int min, int max);
double random_double_number(double min, double max);

random_number.cpp

#include "random_number.hpp"
 
std::random_device r;
std::default_random_engine rnd(r());
 
int random_int_number(int min, int max)
{
  return std::uniform_int_distribution<int>(min, max)(rnd);
}
 
 
double random_double_number(double min, double max)
{
  return std::uniform_real_distribution<double>(min, max)(rnd);
}

References

c/c_random_numbers.txt · Last modified: 2021/04/28 09:15 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki