#include <iostream>
using std::cout;
using std::endl;
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
int main()
{
int a1[ 10 ] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
std::vector< int > v( a1, a1 + 10 ); // copy of a1
std::ostream_iterator< int > output( cout, " " );
cout << "Vector v before random_shuffle: ";
std::copy( v.begin(), v.end(), output );
std::random_shuffle( v.begin(), v.end() ); // shuffle elements of v
cout << "\nVector v after random_shuffle: ";
std::copy( v.begin(), v.end(), output );
cout << endl;
return 0;
}
/*
Vector v before random_shuffle: 1 2 3 4 5 6 7 8 9 10
Vector v after random_shuffle: 9 2 10 3 1 6 8 4 5 7
*/
|