/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package listaexercicios;

/**
 *
 * @author awolf
 */
public class Questao27 {

    public static void imprimeMat(int mat[][]) {
        for (int i = 0; i < mat.length; i++) {
            System.out.println();
            for (int j = 0; j < mat[i].length; j++) {
                System.out.print(mat[i][j] + " ");
            }
        }
    }

    public static void main(String[] args) {
        int matriz[][] = new int[4][4];
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4; j++) {
                matriz[i][j] = 4;
            }
        }

        imprimeMat(matriz);

        for (int i = 0; i < 3; i++) {
            int linha = (int) (Math.random() * matriz.length);
            int coluna = (int) (Math.random() * matriz[linha].length);
            matriz[linha][coluna] = 0;
        }

        System.out.println("\nMatriz modificada");
        imprimeMat(matriz);

        System.out.println("\nSomando linhas");
        for (int i = 0; i < 4; i++) {
            int soma = 0;
            for (int j = 0; j < 4; j++) {
                soma = soma + matriz[i][j];
            }
            System.out.println("Soma da linha " + (i + 1) + " é :" + soma);
        }
    }
}
