📅  最后修改于: 2022-03-11 14:44:45.654000             🧑  作者: Mango
#include
#include
#include
#include
#include
using namespace std;
int main()
{
// First create an instance of an engine.
random_device rnd_device;
// Specify the engine and distribution.
mt19937 mersenne_engine {rnd_device()}; // Generates random integers
uniform_int_distribution dist {1, 52};
auto gen = [&dist, &mersenne_engine](){
return dist(mersenne_engine);
};
vector vec(10);
generate(begin(vec), end(vec), gen);
// Optional
for (auto i : vec) {
cout << i << " ";
}
}