i am trying to write a program to randomly shuffle numbers the program works but everytime i run the programs and get the same numbers shuffled in the same order
output 2 6 9 5 4 3 1 7 8 10
is there a way that i can make it so everytime i run the program it will be in a different order
example
2 3 8 5 9 10 7 1 6 4 (first run)
9 5 6 4 7 3 10 2 8 1 (second run) and so on
my program is at the end
Thanks for help a newbee
Ben
#include <iostream>
using std::cout;
using std::endl;
#include <algorithm>
#include <numeric>
#include <vector>
int main()
{
const int size = 10;
int a1[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
std::vector< int > v( a1, a1 + size );
std:
stream_iterator< int > output( cout, " \n " );
std::random_shuffle( v.begin(), v.end() );
std::copy( v.begin(), v.end(), output );
return 0;
}
output 2 6 9 5 4 3 1 7 8 10
is there a way that i can make it so everytime i run the program it will be in a different order
example
2 3 8 5 9 10 7 1 6 4 (first run)
9 5 6 4 7 3 10 2 8 1 (second run) and so on
my program is at the end
Thanks for help a newbee
Ben
#include <iostream>
using std::cout;
using std::endl;
#include <algorithm>
#include <numeric>
#include <vector>
int main()
{
const int size = 10;
int a1[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
std::vector< int > v( a1, a1 + size );
std:
std::random_shuffle( v.begin(), v.end() );
std::copy( v.begin(), v.end(), output );
return 0;
}