1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| #include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <boost\random.hpp>
#include <boost\bind.hpp>
namespace
{
const unsigned SIZE_VECTOR = 20;
const unsigned RND_MAX = 100;
}
int main()
{
std::vector<int> tab;
boost::random::mt19937 rng;
tab.reserve(SIZE_VECTOR);
std::generate_n(
std::back_inserter(tab)
,SIZE_VECTOR
,boost::bind(boost::random::uniform_int_distribution<>(1,RND_MAX),rng)
);
std::copy(tab.begin(),tab.end(),std::ostream_iterator<int>(std::cout,"\n"));
return 0;
} |