|
|
@@ -1,11 +1,11 @@
|
|
1
|
1
|
import java.util.regex.Pattern;
|
|
2
|
2
|
|
|
3
|
|
-public class Matrix {
|
|
|
3
|
+class Matrix {
|
|
4
|
4
|
private int[][] matrix;
|
|
5
|
5
|
private static Pattern spacePattern = Pattern.compile(" ");
|
|
6
|
6
|
private static Pattern newlinePattern = Pattern.compile("\\n");
|
|
7
|
7
|
|
|
8
|
|
- public Matrix(String matrixAsString) {
|
|
|
8
|
+ Matrix(String matrixAsString) {
|
|
9
|
9
|
String[] rows = newlinePattern.split(matrixAsString);
|
|
10
|
10
|
matrix = new int[rows.length][];
|
|
11
|
11
|
for (int i = 0; i < rows.length; i++) {
|
|
|
@@ -17,11 +17,11 @@ public class Matrix {
|
|
17
|
17
|
}
|
|
18
|
18
|
}
|
|
19
|
19
|
|
|
20
|
|
- public int[] getRow(int rowNumber) {
|
|
|
20
|
+ int[] getRow(int rowNumber) {
|
|
21
|
21
|
return matrix[rowNumber];
|
|
22
|
22
|
}
|
|
23
|
23
|
|
|
24
|
|
- public int[] getColumn(int columnNumber) {
|
|
|
24
|
+ int[] getColumn(int columnNumber) {
|
|
25
|
25
|
int[] column = new int[matrix.length];
|
|
26
|
26
|
for(int i = 0; i < matrix.length; i++) {
|
|
27
|
27
|
column[i] = matrix[i][columnNumber];
|
|
|
@@ -29,11 +29,11 @@ public class Matrix {
|
|
29
|
29
|
return column;
|
|
30
|
30
|
}
|
|
31
|
31
|
|
|
32
|
|
- public int getRowsCount() {
|
|
|
32
|
+ int getRowsCount() {
|
|
33
|
33
|
return matrix.length;
|
|
34
|
34
|
}
|
|
35
|
35
|
|
|
36
|
|
- public int getColumnsCount() {
|
|
|
36
|
+ int getColumnsCount() {
|
|
37
|
37
|
return matrix[0].length;
|
|
38
|
38
|
}
|
|
39
|
39
|
}
|