-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtwoD_array.java
More file actions
39 lines (31 loc) · 950 Bytes
/
twoD_array.java
File metadata and controls
39 lines (31 loc) · 950 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
30
31
32
33
34
35
36
37
38
39
package class_programs;
import java.util.*;
public class twoD_array {
public static void main(String[] args) {
System.out.println("This program is written by\nAshik MR, 4NI19IS017, B section");
int[][] arr = new int[][] {
{3, 0, 6, 5, 0, 8, 4, 0, 0},
{5, 2, 0, 0, 0, 0, 0, 0, 0},
{0, 8, 7, 0, 0, 0, 0, 3, 1},
{0, 0, 3, 0, 1, 0, 0, 8, 0},
{9, 0, 0, 8, 6, 3, 0, 0, 5},
{0, 5, 0, 0, 9, 0, 6, 0, 0},
{1, 3, 0, 0, 0, 0, 2, 5, 0},
{0, 0, 0, 0, 0, 0, 0, 7, 4},
{0, 0, 5, 2, 0, 6, 3, 0, 0}
};
Scanner sc=new Scanner(System.in);
// for(int i=0;i<2;i++) {
// for(int j=0;j<2;j++) {
// arr[i][j]=sc.nextInt();
// }
// }
System.out.println("\nThe elements in the 2D array are");
for (int i=0;i<9;i++) {
for(int j=0;j<9;j++) {
System.out.print(arr[i][j]+ " ");
}
System.out.println();
}
}
}