well the best way for me will be
take an array of N numbers
fill up each elemnt in increasing order from min to max
i.e.
if N = 4
min = 3 and max = 6
then array elements should be like
3,4,5,6
now in a loop
for(i = 0, j= N ; i <= N ; i++,j--){
number = rand()%j;
newNumber = array[number]; /* save it somewhere , or do with it
whatever you want to do ,
this is your new random number.
I am considering that I have to just print N random numbers*/
printf("%d",newNumber);
swap(array[j],array[number]);
}
If you had to do something different than either you will have to
modify above loop
or Your random numbers will be in revrese order in your array.
advantage is aboove code is that it will take exactly N random calls to
genrate N different numbers....
so no colloision
wrote:
> N integers...
> In my code I am generating an array
> of random numbers.