# fifteen move issue

Can anyone see the issue here? It moves "5" from the start position ok, but when it comes to "1" it is just two blank tiles in adjacent squares ("1" disappears). Obviously there is some issue with the "move" function here. Can you help me please?

``````bool move(int tile)
{
int t;
//int xrow; int xcol; int orow; int ocol;
for (int xrow = 0; xrow < d; xrow++)
{
for (int xcol = 0; xcol < d; xcol++)
{
if (board [xrow][xcol] == tile)
{
if (board [xrow - 1][xcol] == 0)
{
t = board [xrow][xcol];
board [xrow][xcol] = board [xrow - 1][xcol];
board [xrow - 1][xcol] = t;
return true;
}
else if (board [xrow + 1][xcol] == 0)
{
t = board [xrow][xcol];
board [xrow][xcol] = board [xrow + 1][xcol];
board [xrow + 1][xcol] = t;
return true;
}
else if (board [xrow][xcol - 1] == 0)
{
t = board [xrow][xcol];
board [xrow][xcol] = board [xrow][xcol - 1];
board [xrow][xcol - 1] = t;
return true;
}
else if (board [xrow][xcol + 1] == 0)
{
t = board [xrow][xcol];
board [xrow][xcol] = board [xrow][xcol + 1];
board [xrow][xcol + 1] = t;
return true;
}
else
{
return false;
}
}
}
}
return false;
}
``````
• Please comment your code and let us know clearly what's the issue, from when you launch the program to when the problem happens. I personally don't get what your problem is. Commented Aug 21, 2016 at 16:44
• When I run the program (d=3) and enter number "3" as a tile to move it works fine. But if I choose tile number "1" to move first it shows me this. ---- 8 7 6-------------------------------------------------------------------------------------------------------------------------------- ----5 4 3------------------------------------------------------------------------- ------------------------------------------------------2 _ _ ------------------------------------------------------------------------"zero" goes to the previous position and "1" disappears. Commented Aug 21, 2016 at 17:58