0

I have an issue making my board in fifteen, i think im doing well but it shows something i can't explain. Can anyone help me? why my board numbers shudenly do this weird thing:

My code:

void init(void)
{
// TODO
int grid[d][d];
int numbers = d * d;
for (int i = 0; i < d; i++)
{
    for (int j = 0; j < d; j++)
    {
        grid[i][j] = numbers - 1;
        numbers -= 1;
    }
}
}


void draw(void)
{
int grid[d][d];
for (int i = 0; i < d; i++)
{
    for (int j = 0; j < d; j++)
    {
        printf("%4i|", grid[i][j]);
    }
    printf("\n");
}
// TODO
}

the board result for 3 to 5 is correct but in 6 this happens:

  0|   0|   0|   0|-1473177792|32714|
576|   0|  27|  26|  25|  24|
 23|  22|  21|  20|  19|  18|
 17|  16|  15|  14|  13|  12|
 11|  10|   9|   8|   7|   6|
  5|   4|   3|   2|   1|   0|
Tile to move: 

and in 7 :

753164144|32764|1009673177|32699|  44|  43|  24|
48|753164128|32764|753163936|32764|  36|  35|
0|   0|   0|   0|   0|   0|1020716864|
32699| 576|   0|  24|  23|  22|  21|
20|  19|  18|  17|  16|  15|  14|
13|  12|  11|  10|   9|   8|   7|
6|   5|   4|   3|   2|   1|   0|
Tile to move: 

in 8:

63|  62|   0|   0|4196272|   0|-1922597488|32767|
 0|   0|   0|   0|-1922597824|32767|-1446706215|32569|
47|  46|  24|  48|-1922597840|32767|-1922598032|32767|
39|  38|   0|   0|   0|   0|   0|   0|
-1435662528|32569| 576|   0|  27|  26|  25|  24|
23|  22|  21|  20|  19|  18|  17|  16|
15|  14|  13|  12|  11|  10|   9|   8|
 7|   6|   5|   4|   3|   2|   1|   0|
Tile to move: 

for 9 the same problem as 8 it starts well but in some point goes crazy

plss help

0

ok I'm retarded, i created a new array instead of usig the one created before, so only changing grid for board works

| improve this answer | |
  • I did this too at my first attempt. :D – MIB Jul 13 '17 at 19:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .