hi i am using Random class for getting random numbers but my requirement is once it generate one no that should not be repeate again pls help me.
相关问题
- Unity - Get Random Color at Spawning
- How do I merge consecutive numbers in a sorted lis
- How to generate a random number, then display it o
- how to randomly loop over an array (shuffle) in ba
- How to fill an array with random numbers from 0 to
相关文章
- why 48 bit seed in util Random class?
- Need help generating discrete random numbers from
- Get random records with Doctrine
- Looking for a fast hash-function
- regular expression to add characters before and af
- Oracle random row from table
- Generate a Random Number between 2 values to 2 dec
- What does Random(int seed) guarantee?
Keep a list of the generated numbers and check this list before returning the next random.
Since you have not specified a language, I'll use C#
The following C# code shows how to obtain 7 random cards with no duplicates. It is the most efficient method to use when your random number range is between 1 and 64 and are integers:
If the random number range is greater than 64, then the next most efficient way to get random numbers without any duplicates is as follows from this C# code:
The drawback with this technique is that it tends to use more memory, but it should be significantly faster than other approaches since it does not have to look through a large container each time a random number is obtained.