using System;
class Program
{
static void Main()
{
char[] поле = { '1', '2', '3', '4', '5', '6', '7', '8', '9' };
char игрок = 'X';
for (int ход = 0; ход < 9; ход++)
{
Console.Clear();
Console.WriteLine($"{поле[0]} | {поле[1]} | {поле[2]}");
Console.WriteLine("--+---+--");
Console.WriteLine($"{поле[3]} | {поле[4]} | {поле[5]}");
Console.WriteLine("--+---+--");
Console.WriteLine($"{поле[6]} | {поле[7]} | {поле[8]}");
Console.WriteLine($"\nИгрок {игрок}, выбери клетку:");
int выбор = Convert.ToInt32(Console.ReadLine()) - 1;
if (поле[выбор] != 'X' && поле[выбор] != 'O')
{
поле[выбор] = игрок;
if (игрок == 'X')
игрок = 'O';
else
игрок = 'X';
}
else
{
Console.WriteLine("Клетка занята!");
ход--;
Console.ReadKey();
}
}
Console.Clear();
Console.WriteLine($"{поле[0]} | {поле[1]} | {поле[2]}");
Console.WriteLine("--+---+--");
Console.WriteLine($"{поле[3]} | {поле[4]} | {поле[5]}");
Console.WriteLine("--+---+--");
Console.WriteLine($"{поле[6]} | {поле[7]} | {поле[8]}");
Console.WriteLine("\nИгра закончена!");
}
}