Nearly early filling of 2-string C#
There's a 5x5. We need to fill it with zeros, and two elements randomly selected by units.
Alberto last edited by
You really need to pick two random indexes from 0 to 24.
Itple easier to do so using standard
i1 = random.Next(25)
You get the first index.
For the second index, 24 values remain, but all values not equal.
i1♪ It's the best way to write this:
i2 = random.Next(24); if (i2 >= i1) i2++;
Okay, now you have to turn every index into a double index of 0 to 4. This is done with help.
x = i / 5; y = i % 5;
It's more obvious. Fill the pool of zeros on the two items counted.