Java
xxxxxxxxxx
public class AddMatrices {
â
public static void main(String[] args) {
int rows = 2, columns = 3;
int[][] firstMatrix = { {2, 3, 4}, {5, 2, 3} };
int[][] secondMatrix = { {-4, 5, 3}, {5, 6, 3} };
â
// Adding Two matrices
int[][] sum = new int[rows][columns];
for(int i = 0; i < rows; i++) {
for (int j = 0; j < columns; j++) {
sum[i][j] = firstMatrix[i][j] + secondMatrix[i][j];
}
}
â
// Displaying the result
System.out.println("Sum of two matrices is: ");
for(int[] row : sum) {
for (int column : row) {
System.out.print(column + " ");
}
System.out.println();
}
}
}
Sum of two matrices is: -2 8 7 10 8 6
Linux - Comment installer anc-api-tools
Linux - Comment installer curvedns
Python - Vérifier si un nombre est positif, négatif ou 0
Linux - Comment installer zenmap
C - Compter le nombre de chiffres dans un entier
C++ - VĂ©rifier si un nombre est premier ou non
C++ - Vérifier l'année bissextile
JavaScript - VĂ©rifier si une chaĂźne commence et se termine par certains caractĂšres
C - Trouver le plus grand nombre à l'aide de l'allocation de mémoire dynamique
Kotlin - Arrondir un nombre à n décimales
Linux - Comment installer zfs-test
Kotlin - Inverser un nombre
C++ - Trouver le quotient et le reste
Linux - Comment installer xbitmaps
Kotlin - Trouver la factorielle d'un nombre
Java - Inverser un nombre
Linux - Comment installer zstd
GoLang - Intervalle
We have been online since 2021 and 1 millions of people around the globe have visited our website since then
More visitors every month