Could someone show me an example of randomizing multidimensional vectors, or even arrays? I found a tutorial for one dimensional vectors but can't figure it out.
Code: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( std::cout, " " ); std::cout << "Vector v before random_shuffle: "; std::copy( v.begin(), v.end(), output ); std::random_shuffle( v.begin(), v.end() ); // shuffle elements of v std::cout << "\nVector v after random_shuffle: "; std::copy( v.begin(), v.end(), output ); std::cout << std::endl;




Reply With Quote