{{#items}}

{{text}}

{{/items}} {{ctaText}}

{{#items}} {{/items}}

showing results for - "create random vectors c 2b 2b"

Felipe

16 Oct 2019

```
1#include <random>
2#include <algorithm>
3#include <iterator>
4#include <iostream>
5#include <functional>
6
7using namespace std;
8
9int main()
10{
11 // First create an instance of an engine.
12 random_device rnd_device;
13 // Specify the engine and distribution.
14 mt19937 mersenne_engine {rnd_device()}; // Generates random integers
15 uniform_int_distribution<int> dist {1, 52};
16
17 auto gen = [&dist, &mersenne_engine](){
18 return dist(mersenne_engine);
19 };
20
21 vector<int> vec(10);
22 generate(begin(vec), end(vec), gen);
23
24 // Optional
25 for (auto i : vec) {
26 cout << i << " ";
27 }
28
29
30}
31
```

similar questions

initialize vector of vector c 2b 2brandom numbers c 2b 2bshuffle vector c 2b 2bcreate vectors of vectors c 2b 2bhow to make a random number in c 2b 2bc 2b 2b randommaking random numbers in c 2b 2bcpp randrandom number c 2b 2brand 28 29 c 2b 2brng cpprandom number c 2b 2brandom number in c 2b 2brandom in c 2b 2brandom number cpphow to get a random element from a vector c 2b 2b stringhow to create a vector in c 2b 2bgenerate random double c 2b 2bselect one random element of a vector in c 2b 2brandom number generator c 2b 2bqueries leading to this page

create vector of random numbers c 2b 2bcreate vector of random numbers in c 2b 2bvector random c 2b 2bc 2b 2b vector random elementc 2b 2b random element from vectorget random element from vector c 2b 2brandom element from vector c 2b 2bcreate a vector with random numbers in c 2b 2bcreate random vectors c 2b 2bc 2b 2b random element of vectorchoose random from vector c 2b 2bc 2b 2b how to create a randomized vectorrandom vector of vectors cppc 2b 2b get random from vectorrandom element from a vector c 2b 2brandom element in vector c 2b 2bmake an vector of random number c 2b 2bc 2b 2b random vectorc 2b 2b random vector elementvector array random numbers c 2b 2bcreate vector with random numbers c 2b 2bcreate random vector integer cppvector of random numbers c 2b 2bgenerate random vectors c 2b 2bgetting random element from vector c 2b 2bgenerate vector random c 2b 2bgenerate random vector cppc 2b 2b generate the vector randomget random elements from vector c 2b 2bget random value from vector c 2b 2bcreate random vectors c 2b 2b your answer for

you will get a confirmation link on this - you will have to click that for successful submission of your answer. we require this to keep the website free of spam, bots and unhelpful content

please ensure to add code which is syntactically corrent and executes properly

ask question on maxinterview

you will get a confirmation link on this - you will have to click that for successful submission of your question. we require this to keep the website free of spam, bots and unhelpful content

please be clear, to the point and respectful