Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Last active February 11, 2020 06:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/e8f7eb12beb7c72f94dfcbcefda82442 to your computer and use it in GitHub Desktop.
Save parzibyte/e8f7eb12beb7c72f94dfcbcefda82442 to your computer and use it in GitHub Desktop.
int[][] matriz = { { 11, 1232, 386, 432 }, { 47, 454, 254, 353 } };
int sumatoria = 0; // Aquí iremos sumando cada valor
int cantidadDeElementos = 0; // Contar los elementos
// Recorremos la matriz
for (int x = 0; x < matriz.length; x++) {
for (int y = 0; y < matriz[x].length; y++) {
int numeroActual = matriz[x][y];
sumatoria = sumatoria + numeroActual;
cantidadDeElementos = cantidadDeElementos + 1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment