Hello everyone,I'm having a problem with an exercise in C,I hope more experienced programmers will help me.I want to create a simple version of the game Tic-Tac-Toe.In my edition there will be a 3x3 matrix.The 2 players that will play the game will start to fill the matrix with the symbols "X" and "O".When a player completes a column or a row or a arriswise the program ends with showing this message "Congratulation Player X. You Won!", where x is 1 or 2 depending on which player won.This is an example of execution:

*******************
Turn 1: Player 1 ('X')
*******************

Enter Row: 1
Enter Column: 1
0 1 2
0
1 X
2
*******************
Turn 2: Player 2 ('O')
*******************

Enter Row: 1
Enter Column: 0
0 1 2
0
1 O X
2

*******************
Turn 3: Player 1 ('X')
*******************

Enter Row: 0
Enter Column: 0
0 1 2
0 X
1 O X
2

*******************
Turn 4: Player 2 ('O')
*******************

Enter Row: 2
Enter Column: 2
0 1 2
0 X
1 O X
2 O

*******************
Turn 5: Player 1 ('X')
*******************

Enter Row: 0
Enter Column: 2
0 1 2
0 X X
1 O X
2 O

*******************
Turn 6: Player 2 ('O')
*******************

Enter Row: 2
Enter Column: 0
0 1 2
0 X X
1 O X
2 O O
*******************
Turn 7: Player 1 ('X')
*******************

Enter Row: 0
Enter Column: 1
0 1 2
0 X X X
1 O X
2 O O

Congratulation Player 1. You Won!


I will appreciate any answers! :)

Some pseudo code

while(true)
{
        // Take the I/P from the user
        // Check if the first row has all X's
        // Check if the second row has all X's
        ....
        ...
         // CHeck for all rows, all columns, diagonally for X's and 0's
}

Edited 5 Years Ago by abhimanipal: n/a

This article has been dead for over six months. Start a new discussion instead.