How to add two 3×3 matrices by using 1D array in java ??? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to add two 3×3 matrices by using 1D array in java ???

11th Jan 2018, 4:51 AM
Abhishek Gunjan
Abhishek Gunjan - avatar
3 Answers
+ 8
int[] matrix1 = {1,2,3,4,5,6,7,8,9}; int[] matrix2 = {5,2,5,7,9,6,4,8,3}; int[] sum = new int[matrix1.length] for (int i = 0;i < matrix1.length;i++) sum[i] = matrix1[i] + matrix2[i];
11th Jan 2018, 11:59 AM
David Akhihiero
David Akhihiero - avatar
+ 7
Isn't it better to add matrices using 2D arrays, that makes more sense
11th Jan 2018, 6:23 AM
David Akhihiero
David Akhihiero - avatar
+ 1
but someone has asked me the same question
11th Jan 2018, 11:44 AM
Abhishek Gunjan
Abhishek Gunjan - avatar