Given a two-dimensional array of N * N, which contains several rectangles. Different rectangles do not touch or overlap. Inside the entire rectangle is filled with 1-kami. In the array:
1) a [i, j] = 1, if the element (i, j) belongs to some rectangle
2) a [i, j] = 0, otherwise. getRectangleCount
should return the number of rectangles.
The main
method does not participate in testing:
public class ArrayWithRectsGetThemCount21032016 { public static void main(String[] args) { byte[][] a = new byte[][]{ {1, 1, 0, 0}, {1, 1, 0, 0}, {1, 1, 0, 0}, {1, 1, 0, 1} }; int count = getRectangleCount(a); System.out.println("count = " + count + ". Должно быть 2"); } public static int getRectangleCount(byte[][] a) { return 0; } }
return 0;
. - Igor