Did you make sure to add this code?
bool set = false;
while(!set)
{
aux2=int( rand()%20);
aux3=int( rand()%20);
if(math[aux2][aux3]==0)
{
math[aux2][aux3] = 1;
set = true;
}
}
bool set = false;
while(!set)
{
aux2=int( rand()%20);
aux3=int( rand()%20);
if(math[aux2][aux3]==0)
{
math[aux2][aux3] = 1;
set = true;
}
}
To copy to clipboard, switch view to plain text mode
The while loop should keep running until you have set a value to 0. This added in conjunction with the initialization to 0 should fix your problem. Also, if you have the bool in the wrong place then the loop will
not work.
Bookmarks