Can someone help and see whats wrong with my codes? it was suppose to display only even number of 0,2,4 or 8 in only 2 of the tiles but its displaying the number 32 in all 16 tiles. here's my codes. sorry in advance if my codes are not readable.
/*Adding random number to the array*/
void randomno(int mine[4][4])
{
int x, a, b;
int counter = 0;
int sr = 1;
if(counter == 4 * 4)
{return;}
counter++;
sr++;
for(x=0; x<2; x++)
{
int no = 0;
bool stop;
stop = false;
while(!=stop)
{
no = ((rand()%3)*2) ;
if(no==2 || no==4 || no==8)
{ stop = true; }
}
stop = false;
while(!=stop)
{
a = rand() % 4;
b = rand() % 4;
if(mine[a][b] == 0)
{
mine[a][b] = no;
stop = true;
}
}
}
}
Aucun commentaire:
Enregistrer un commentaire