Although I have seen other people encounter this problem before, I can leave it empty.
However, I recently thought about how to find a solution, so I didn't check the information.
Let's talk about my personal ideas. I think it's really a tough start. For example, I want to generate two random numbers that do not repeat between 1 and 5.
If 3 is generated for the first time, then the number X generated for the second time determines if this X has already appeared. If so, try again.
Random rnd = <> lstResult = List<>(lstResult.Count < ){ temp = rnd.Next(,(lstResult.Contains(temp))
( i = ;i < ;i++)
Then a random number is generated.
rndNum = rnd.Next(i ,);
Use rndNum as the index of the arrIndex array.
Exchange two numbers, arrIndex [I] And arrIndex [rndNum ].
Random Number rndNum = rnd. next (,) <= [] <and I (secondary random number rndNum = rnd. next (,) <= [] <and I (secondary random number rndNum = rnd. next (,) <= [] <and I (secondary random number rndNum = rnd. next (,) <= [] <and I (secondary random number rndNum = rnd. next (,) <= [] <and I (
In the above step, two 7 numbers are generated from the random number, but if we use this 7 as an index to disrupt an ordered set, then we can retrieve the x on the left as the random number we want.
Code:
[] arrNums = [ ( i = ; i < ; i++= i + = ( i = ; i < ; i++ index = rnd.Next(i, temp ===
There are many ways to generate non-repeated random numbers on the Internet. For more information, I just came up with what I did at the time. reference ,,,