+ 3
How to make an array with random numbers?
3 Answers
+ 3
#include <random>
#include <array>
int main()
{
std::mt19937_64 engine;
std::uniform_int_distribution<> distribution{0, 99};
std::array<int, 10> arr;
for (auto &x : arr)
x = distribution(engine);
}
+ 1
fill each position of the array with a value returned from random function
for loop{
array[i]= random()
}
just remember that you have to calibrate the result, meaning that random returns something between 0 and 1, so you need to multiply it by 10 and so on.