You are viewing a single comment's thread. Return to all comments →
Why I'm getting wrong answer if my answer is correct? How should I submit my code?
public class Main { public static void main(String[] args) { int[][] m1 = new int[3][3]; int[][] m2 = new int[3][3]; int[] sum = new int[9]; int h = 1; m1[0][0] = 1; m1[0][1] = 2; m1[0][2] = 3; m1[1][0] = 2; m1[1][1] = 3; m1[1][2] = 4; m1[2][0] = 1; m1[2][1] = 1; m1[2][2] = 1; m2[0][0] = 4; m2[0][1] = 5; m2[0][2] = 6; m2[1][0] = 7; m2[1][1] = 8; m2[1][2] = 9; m2[2][0] = 4; m2[2][1] = 5; m2[2][2] = 7; h=0; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { sum[h] = m1[i][j] + m2[i][j]; h++; } } for (int i=0; i<9; i++){ System.out.println(sum[i]); } } }
Seems like cookies are disabled on this browser, please enable them to open this website
Linear Algebra Foundations #1 - Matrix Addition
You are viewing a single comment's thread. Return to all comments →
Why I'm getting wrong answer if my answer is correct? How should I submit my code?