i've got a problem with srand(), it works only when I fill parameter with number, for example srand(1234), but when I try to use it with 'n' or with time (as below), then randint keeps returning the same seed.
#include <iostream>
#include <algorithm>
#include <experimental/random>
#include <cstdlib>
#include <ctime>
using namespace std;
int main() {
srand(time(nullptr));
for (int i = 0; i < 4; ++i) {
int random = experimental::randint(0, 9);
cout << random;
}
}
Thanks for your time.
Aucun commentaire:
Enregistrer un commentaire