Question: use c code to solve this : In a Connect - 4 , two players compete against each other to form a continuous set of

use c code to solve this :
In a Connect-4, two players compete against each other to form a continuous set of at least 4 pieces horizontally, vertically, or diagonally in a 6x7 board. That is, the winner has 4 pieces or more formulating a line with no interruption from the pieces of the opponent. In our version of the game, a player may play 2 times consecutively without giving the turn to the opponent. This means that you cannot rely on the number of pieces to determine the winner. When inserted, the pieces are dragged to the bottom of the board as shown below. Player 1 pieces are marked 'X', player 2 pieces are marked 'O'. Empty slots are marked with a '.'. In the shown map, player 2 wins because 4'O's are diagonally set from the bottom left to the top right. ................. X O .... X O O .... O X X . X . O X O X . X
You will be given a map of a Connect-4 game where one player wins. You are required to determine the winner. Remember that the game stops once one player wins, so there is no possibility that the two players win at the same time. However, a game may end with a draw where the board is full and none of the two players can connect 4 pieces. If player 1 wins, you should print 1. If player 2 wins, you should print 2. If there is no winner, you should print 0.
Input Format
A 6 rows X 7 columns map describing the shape of the board
Constraints
No constraints
Output Format
A single number specifiying the winner of the game: 1 or 2 for player 1 or player 2, respectively. If there is no winner, 0 is printed
Sample Input 0
.......
.......
... X O ..
.. X O O ..
.. O X X . X
. O X O X . X
Sample Output 0
2
Sample Input 1
.......
.......
.......
. O .....
O O O ....
X X X X ...
Sample Output 1
1
Sample Input 2
X X X O X X X
O O O X O O O
X X O O O X O
O O X X O O X
X X O O X X O
X X O O X O X
Sample Output 2
0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!