can anybody help me..
Multidimensional Array
Use a two-dimensional array (for example of 3 by 3) to simulate the addition operation of two matrices.
Sample output:
the first matrix:
1 2 3
1 0 1
1 2 1
the second matrix:
1 1 1
2 2 2
3 3 3
The total of two matrices:
2 3 4
3 2 3
5 4 5
i have make this.. but i don't know how to add the addition part..
this is my coding..
public class LabExecriseC
{
public static void main(String args[])
{
String output="";
int total;
int array1[][]={{1,2,3},{1,0,1},{2,1,2}};
int array2[][]={{1,1,1},{2,2,2},{3,3,3}};
output=output+"The First Matrix:\n";
for(int row = 0; row<array1.length; row++)
{
for (int column=0; column<array1[row].length; column++)
output = output+array1[row][column]+" ";
output = output+ "\n";
}
output = output+ "\nThe Second Matrix:\n";
for (int row = 0; row<array2.length; row++)
{
for (int column=0; column<array2[row].length; column++)
output = output+array2[row][column]+" ";
output = output+ "\n";
}
output=output+"Sum of two Matrix:\n";
System.out.println(output);
}
}
*or you have the other ways to settel this problem
1 answer
I get
the first matrix:
1 2 3
1 0 1
1 2 1
the second matrix:
1 1 1
2 2 2
3 3 3
The total of two matrices:
2 3 4
3 2 3
4 5 4
in flow chart form:
do 1 from n = 1 to 3
do 1 from m = 1 to 3
1 output (n,m) = inputA(n,m) + inputB(n,m)
do 3 for n = 1 to 3
3 print or store output(n,m) for m = 1 to 3
end