When I read some question to write random nuber generator ,I saw that function and it
efficient but it is written in C#. I want see that function in form of c
language,can anyone help?
IEnumerable<int> ForLargeQuantityAndRange(int quantity, int range)
{
for (int n = 0; n < quantity; n++)
{
int r = Random(range);
while (!used.Add(r))
r = Random(range);
yield return r;
}
}
Questions regarding number generators for C have been asked before here on SO, such as in the article “Create Random Number Sequence with No Repeats“.
I’d suggest looking at the above article to see if anything is suitable and provides a useful alternative to the standard rand() function in C, assuming that you’ve already looked at the latter and rejected it.