Home > Net >  Master has recommended a produce don't repeat random number method?
Master has recommended a produce don't repeat random number method?

Time:01-23

Can generate continuous not repeat random number method?

CodePudding user response:

1. Generate a random number, thrown into the HashTable;
2. Generate a random number, throw in a List, and then to heavy with Distinct;
3. Generate a random number, if the target List does not include the number, the random number added;
4. Dictionary , the Key=1, 2, 3,... , filling the Value using a random number, and then sort by Value, and output the corresponding Key,

CodePudding user response:

Can say the application scenario?

CodePudding user response:

See how much you need to generate to generate an ordered array, after the order is a one out there will not be repeated,
  • Related