-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharray4.java
36 lines (36 loc) · 936 Bytes
/
array4.java
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
30
31
32
33
34
35
36
import java.util.Scanner;
class array4
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.println("Give row and column for 2D array : ");
int n = sc.nextInt();
int m = sc.nextInt();
int a[][] = new int[n][m];
System.out.println("Give values of array : ");
for(int i=0; i<n; i++)
{
for(int j=0; j<m; j++)
{
a[i][j] = sc.nextInt();
}
}
for(int i=0; i<n; i++)
{
for(int j=0; j<m; j++)
{
System.out.println("a["+i+"]["+j+"]: "+a[i][j]);
}
}
System.out.println("Matrix format : ");
for(int i=0; i<n; i++)
{
for(int j=0; j<m; j++)
{
System.out.print(a[i][j]+ " ");
}
System.out.println();
}
}
}