private static bool CheckRow(int row, int[,] board, int player)
return board[row, 0] == player
&& board[row, 1] == player
&& board[row, 2] == player;
private static bool CheckCol(int col, int[,] board, int player)
return board[0, col] == player
&& board[1, col] == player
&& board[2, col] == player;
static bool Winner(int[,] board, int player)
for(int i = 0; i < board.GetLength(0); i++)
if (CheckRow(i, board, player))
for(int i = 0; i < board.GetLength(1); i++)
if (CheckCol(i, board, player))
public static void Main()
TestPlayer1FirstDiagnal();
TestPlayer1SecondDiagnal();
static void TestNoWinner()
int[,] board = {{1,1,0}, {0,0,0}, {0,0,0}};
Console.WriteLine(!Winner(board, 1) + ": TestNoWinner");
static void TestPlayer1FirstRow()
int[,] board = {{1,1,1}, {0,0,0}, {0,0,0}};
Console.WriteLine(Winner(board, 1) + ": TestPlayer1FirstRow");
static void TestPlayer1SecondRow()
int[,] board = {{0,0,0}, {1,1,1}, {0,0,0}};
Console.WriteLine(Winner(board, 1) + ": TestPlayer1SecondRow");
static void TestPlayer1ThirdRow()
int[,] board = {{0,0,0}, {0,0,0}, {1,1,1}};
Console.WriteLine(Winner(board, 1) + ": TestPlayer1ThirdRow");
static void TestPlayer1FirstCol()
int[,] board = {{1,0,0}, {1,0,0}, {1,0,0}};
Console.WriteLine(Winner(board, 1) + ": TestPlayer1FirstCol");
static void TestPlayer1SecondCol()
int[,] board = {{0,1,0}, {0,1,0}, {0,1,0}};
Console.WriteLine(Winner(board, 1) + ": TestPlayer1FirsCol");
static void TestPlayer1ThirdCol()
int[,] board = {{0,0,1}, {0,0,1}, {0,0,1}};
Console.WriteLine(Winner(board, 1) + ": TestPlayer1FirsCol");
static void TestPlayer1FirstDiagnal()
int[,] board = {{1,0,0}, {0,1,0}, {0,0,1}};
Console.WriteLine(Winner(board, 1) + ": TestPlayer1FirsCol");
static void TestPlayer1SecondDiagnal()
int[,] board = { {0,0,1}, {0,1,0}, {1,0,0}};
Console.WriteLine(Winner(board, 1) + ": TestPlayer1FirsCol");