Hello. I´m looking for a good way to make a array in random order. But I really cant come up with anything good. Thought of something like this(sorry if syntax is wrong, but I guess you can see what I´m trying to do):
Just one problem here is that I might take same numbers from the first array many times. Maybe can be solved by setting the value taken from first array to "null" into the while{} somehow? Feels like a bad solution. Or? What do you think. Any tips?Code:// variable to set the number in correct place in second array int i = 0; // Create 1 array with values and one where we will make the numbers in random order int[3] numbers = {1,2,3}; int[3] randomNum = {}; // run as long as the last element in the second array is empty while(randomNum[2] == null){ // take a random element from first array and put it into the second array int random = rand()%2; randomNum[i] = numbers[random]; i++; }