I need help to create an algorithm to make 9 random numbers. Each number must not be equal to any other. Restated as 9 random numbers from 1-9.
I had something like this in mind:
int[] numlist = new int[9]; Random rand = new Random(); int temp; foreach (int i in numlist) { temp = rand.Next(1, 10); //check if temp is already a value of a lower index in numlist //if so, rolls another random number and checks it again... numlist[i] = temp; } I had a method that had ifs inside for loops inside while loops inside foreach loops and such...