I've tried this program with libstdc++, libc++ and dinkumware:
#include <iostream>
#include <algorithm>
#include <vector>
#include <random>
#include <functional>
#include <limits>
int main()
{
std::vector<int> v(10);
std::mt19937 rand{0};
std::uniform_int_distribution<> dist(
1, 10
);
std::generate_n(v.begin(), v.size(),
std::bind(dist, rand));
for (auto i : v)
std::cout << i << " ";
}
Output respectively is:
6 6 8 9 7 9 6 9 5 7
6 1 4 4 8 10 4 6 3 5
5 10 4 1 4 10 8 4 8 4
The output is consistent for each run but as you can see, they're different. Explain?
Aucun commentaire:
Enregistrer un commentaire