Hello every one...i need little help....i want to know that is there any way to use rand to generate random numbers between two limits let say from 0 to 100 such that one number comes only one time....if it is possible then how can i do that...thanks
I can point out at least two ways to achieve this. The first is to use std::set for keeping random numbers. The second is to use std::bit, for example, std::bit<100> and to set a corresponding bit for a given random number.
int Rand(int a, int b)
{
// return a random number in range [a, b]
time_t t;
t=time(NULL);
int r=t%rand();
r=(r*r+rand())%1010101;
r=2*r+rand();
return a+r%(b-a);
}