Answers for "find the position surrounded by the opposite no in a 2d array"

0

find the position surrounded by the opposite no in a 2d array

int[] rowNbr = { -1, -1, -1, 0, 0, 1, 1, 1 };
            int[] colNbr = { -1, 0, 1, -1, 1, -1, 0, 1 };
            for (int x = 0; x < 8; x++)
            {
                int facX = rowNbr[x];
                int facY = colNbr[x];
                try
                {
                    for (int i = 1; i < length; i++)
                    {
                        if (pieces[click.X + i * facX, click.Y + i * facY] == 0) break;
                        if (pieces[click.X + i * facX, click.Y + i * facY] == (byte)num)
                        {
                            for (int j = i - 1; j > 0; j--)
                            {
                                pieces[click.X + j * facX, click.Y + j * facY] = (byte)num;
                            }
                            break;
                        }
                    }
                }
                catch { } 
            }
Posted by: Guest on March-26-2021

Code answers related to "find the position surrounded by the opposite no in a 2d array"

Browse Popular Code Answers by Language