mardi 4 octobre 2016

C++ random_shuffle is always giving the same results

The following call for random shuffle is always giving the same results for the vector v

vector<int> v = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
srand(time(0));
random_shuffle(v.begin(), v.end());

I've tried compiling using

g++ -std=c++0x
g++ -std=c++11

But both give the same results so I don't really understand what's going on.

Aucun commentaire:

Enregistrer un commentaire