Okay guys, I'm an idiot apparently, and can't figure out this simple simple problem.
The rest of my code isn't worth anything, so I'll just post relevant code. I already know WHY it's broken, but I don't know HOW to fix it. I'm really just looking more for pseudocode to give me a starting point.
What I'm trying to do is make an array called "temp", and store in each of its 5 indices a unique random number (these numbers will be used later as indices to a different array). It's not simply a matter of initializing it from 1 to 5 and using a shuffle though because the random numbers can be up to the number of vertices in my graph, numVertices.
int place = -1;
int temp[5] = {-1};
for(int i = 0; i < 5 || i < numVertices; i++){
do{
place = rand();
place = (double)place / RAND_MAX * numVertices;
temp[i] = place;
} while(place == temp[0] or
place == temp[1] or
place == temp[2] or
place == temp[3] or
place == temp[4]); ......`
Clearly, my code gets stuck in an infinite loop because it compares place (the random index I'm storing into a different array) to temp[i], and after it performs the operation it will always equal temp[i]. What I'm TRYING to do is compare it to the others and go "If it matches one of the stored numbers already, randomize place again until it doesn't match, then store it in the next slot in temp." However, I can't for my life think of how to do this..