-
-
Save parzibyte/130e4ccbd0e222334b4266301e95fb41 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void sumaColumnas(int[][] matriz) { | |
// Imprimir la matriz normalmente | |
imprimirMatriz(matriz); | |
// Debajo de ella imprimir una línea divisora | |
for (int x = 0; x < matriz[0].length; x++) { | |
System.out.print("___"); | |
} | |
System.out.println(); | |
// Luego recorrer por columna y sumar | |
for (int x = 0; x < matriz[0].length; x++) { | |
int suma = 0; | |
for (int y = 0; y < matriz.length; y++) { | |
suma += matriz[y][x]; | |
} | |
System.out.printf("%d ", suma); | |
} | |
System.out.println(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment