-
what is this doing??
I have been looking at code for a magic square problem and have no idea what this code is doing. Could you guys please help me?
Code:
for (count = 2; count <= max_count; count++)
{
row = (i - 1 < 0) ? (size - 1) : (i - 1); // up
col = (j - 1 < 0) ? (size - 1) : (j - 1); // left
//i know what this is doing just need help with the above
if (square[row][col] != 0)
{
i ++;
i = i % size;
}
else
{
i = row;
j = col;
}
square[i][j] = count;
}
-
its another way of saying if else...
-
As in
Code:
if ( i - 1 < 0 ) {
row = size - 1;
} else {
row = i - 1;
}