Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'. A region is captured by flipping all 'O's into 'X's in that surrounded region. For example, for the following board, X X X X X O O X X X O X X O X X After capturing all regions, the board becomes X X X X X X X X X X X X X O X X The algorithm should take an input file, named “input.txt”, and output the resulting board in the console. Sample input.txt 6 X X X X X O X O X O O X X X O O O X X X X O X X X O X X O O X X X X X X The first line is a number indicating the size of the board; in the above example, 6 means the board is . Output for in console: X X X X X O X X X X X X X X X X X X X X X X X X X X X X O O X X X X X X
Use C++ language
Can you please give me a code that runs properly this time
Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'.
A region is captured by flipping all 'O's into 'X's in that surrounded region.
For example, for the following board,
X X X X
X O O X
X X O X
X O X X
After capturing all regions, the board becomes
X X X X
X X X X
X X X X
X O X X
The
Sample input.txt
6
X X X X X O
X O X O O X
X X O O O X
X X X O X X
X O X X O O
X X X X X X
The first line is a number indicating the size of the board; in the above example, 6 means the board is .
Output for in console:
X X X X X O
X X X X X X
X X X X X X
X X X X X X
X X X X O O
X X X X X X

Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images









