📜  在二维数组中找到由相反的 no 包围的位置 - 无论代码示例

📅  最后修改于: 2022-03-11 14:58:44.129000             🧑  作者: Mango

代码示例1
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 { } 
            }