The following call for random shuffle is always giving the same results for the vector v
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;
int main(){
vector<int> v = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
srand(time(0));
random_shuffle(v.begin(), v.end());
for (int i = 0; i < v.size(); ++i) printf("%d ", v[i]); printf("\n");
printf("%d\n", rand() % 100);
return 0;
}
I've tried compiling using
g++ -std=c++0x
g++ -std=c++11
But both give the same results every time so I don't really understand what's going on.
$./a.out
7 1 4 6 8 9 5 2 3 10
26
$ ./a.out
7 1 4 6 8 9 5 2 3 10
41
$ ./a.out
7 1 4 6 8 9 5 2 3 10
39