I am having a lot of trouble regarding trying to shuffle arrays. I have a data file that the user interactively chooses. The file contains to sets of data. The first item is a 5 digit number and the second item is a character ('C', 'D', 'E', or 'R'). For example, the file looks like this (except it contains 15 lines):
I have created two parallel arrays:
1 2 3 4 5
constint arraySize = 15;
// array for first item
// array for second item
I have to randomize these parallel arrays but I am NOT allowed to use random_shuffle or anything in the STL. I am also not allowed to have any of the elements repeat. I have been trying a multitude of things but can not seem to come up with any code that works at all. Can anyone provide some insight?
Actually you would not need to use the shuffle tool if you use a loop function
( i.e. while or for) and a series of if and if else statements you can make your program check to see if the random number generated by your random number generator array has already been produced. You need to write somewhere in your program what happens if the array has already been chosen so it does not happen again.
Here is a hint to get you started
your random array should initially look this:
RandomSongArray[a] = rand ()% NUM
where a is some non constant integer defined by your for loop or somewhere in your while loop and NUM is the
size of your array (in this instance 15)