I'm a newbienew to programming and. I have a question regarding the usage of c++11 random header to generate random numbers caught my eye. I have been tryingtried to learn it for some time, but I was unsuccessful. Recently, II've tried this waythe following approach and it worked. Any adivceadvice on how to improve it or. Is there a bettergood source to learn it frommore about this?
Here's the code:
#include <iostream>
#include <random>
#include <ctime>
int main()
{
std::default_random_engine random_engine(time(0));
for (int i = 1; i <= 100; i++)
{
std::uniform_int_distribution<int> num(1, 100);
std::cout << i << "==> " << num(random_engine) << std::endl;
}
return 0;
}