Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Programming150221i2 {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int[][] mat ={{3,4,8}, {9,5,2}, {1,6,0}};
- int sum = 0;
- for (int i = 0; i < mat.length; i++) {
- int[] currentRow = mat[i];
- for (int j = 0; j < currentRow.length; j++) {
- sum += currentRow[j];
- }
- }
- System.out.println("The sum of the matrix is = " + sum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement