1]create a matrix with a given dimension NxN
2]create a function that will fill the matrix with random boolean values
3]write into a text file the coordinates of all cells that satisfy all the
following conditions:
The upper neighbor is TRUE
The left neighbor is FALSE
The right neighbor is FALSE iff (= if and only if) the bottom neighbor is
TRUE, or vice versa.
4] read the text file and restore the matrix.
for you to avoid violating the bounds then you need to limit your loops,
if i == x coord and j == y coord then your working loops should be
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
for(int i=1;i<N-1;i++)
{
for(int j=1;j<N-1;j++)
{
/// those cell with either no
///left||right||upper||bottom {i.e cells on the edges} neigbours don't satisfy
///your conditions and will be lost
//you can now safely check for those conditions given by @KBW
//The upper neighbor is TRUE
//The left neighbor is FALSE
//The right neighbor is FALSE iff (= if and only if) the bottom neighbor is
//TRUE, or vice versa.
}
}