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! :)

Recommended Answers

All 2 Replies

Its not about answers, its about guidance. Please post the code that you have completed so far.

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
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.