0
is it rand() or rand(x)?
We have declared the variable as x and applied the constraints to it. Then is it rand() or rand(x)?
2 Respostas
+ 2
To apply constraints to rand, we do :
rand()%x; // Rand accepts no argument.
Which returns a number in the range 0 to x-1.
To get a number in range L -> U, you do :
L + (rand()%(U-L+1));
This returns a number in the range L to U, both L and U included as the possible outcome.
0
thanks bro