-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddMatrix.java
More file actions
34 lines (26 loc) · 733 Bytes
/
Copy pathAddMatrix.java
File metadata and controls
34 lines (26 loc) · 733 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import java.util.*;
public class AddMatrix {
public static void main(String[] args)
{ int row=3,col=3;
Scanner scanner = new Scanner(System.in);
int [][] m1=new int[row][col];
int [][] m2=new int[row][col];
int [][] m3=new int[row][col];
for(int i=0;i<row;i++)
{for(int j=0;j<col;j++)
{
m1[i][j]=scanner.nextInt();
m2[i][j]=scanner.nextInt();
m3[i][j]=m1[i][j]+m2[i][j];
}
}
for(int i=0;i<row;i++)
{
for(int j=0;j<col;j++)
{
System.out.print(m3[i][j]+" ");
}
System.out.println();
}
}
}