I want to generate a random number from a specific range in each iteration
for (int i = 0; i < 10; i++)
{
v1[i] = rand() % n;
}
This code will generate a number between 0
and 9
. However, I do not want the selected number to be the same as the index i
. For example, if I am in the first iteration (ie: i == 1
), I want the random number to be either 0, 2, 3, 4, 5, 6, 7, 8, 9 and not 1.
Can someone help me in this?