Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int matrixElementsSum(int[][] matrix) {
- int[] zeroInColumn = new int[matrix[0].length];
- int sum = 0;
- for (int i = 0; i < matrix.length; i++) {
- for (int j = 0; j < matrix[i].length; j++) {
- if (matrix[i][j] == 0) {
- zeroInColumn[j] = 1;
- }
- if (zeroInColumn[j] != 1) {
- sum += matrix[i][j];
- }
- }
- }
- return sum;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement