Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- class Program
- {
- static void Main(string[] args)
- {
- string [] array = new string[9];
- int counter = 0;
- try
- {
- FileStream fs = new FileStream(@"C:\Users\user_2.F227-11\Desktop\board.txt", FileMode.Open);
- StreamReader readin = new StreamReader(fs);
- while (!readin.EndOfStream)
- {
- string text = readin.ReadLine();
- string[] boardLocation = text.Split(' ');
- for (int i = 0; i < 3; i++)
- {
- array[i] = boardLocation[0];
- array[i+1] = boardLocation[1];
- array[i+2] = boardLocation[2];
- Console.Write(boardLocation[i] + " " + boardLocation[i + 1] + " " + boardLocation[i + 2]);
- Console.WriteLine();
- i = i+3;
- }
- }
- for (int a = 0; a <= 6; a++)
- {
- if (array[a] == "O" && array[a+1] == "O" && array[a+2] == "O")
- {
- Console.WriteLine("Player x wins");
- }
- else if (array[a] == "X" && array[a + 1] == "X" && array[a + 2] == "X")
- {
- Console.WriteLine("Player y wins");
- }
- }
- readin.Close;
- fs.Close;
- }
- catch (Exception e) { }
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement