-
Notifications
You must be signed in to change notification settings - Fork 0
/
multi-dim.java
46 lines (41 loc) · 1.08 KB
/
multi-dim.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
37
38
39
40
41
42
43
44
45
46
package src.arrays;
class twoDim {
public static void main(String[] args) {
int twoD[][] = new int[4][5];
int i, j ,k = 0;
for(i = 0; i < 4; i++) {
for(j = 0; j < 5; j++) {
twoD[i][j] = k;
k++;
}
}
for(i = 0; i < 4; i++) {
for(j = 0; j < 5; j++) {
System.out.print(twoD[i][j] + " ");
}
System.out.println();
}
}
}
class threeDim {
public static void main(String[] args) {
int threeD[][][] = new int[4][5][6];
int i, j, k;
for(i = 0; i < 4; i++) {
for(j = 0; j < 5; j++) {
for(k = 0; k < 6; k++) {
threeD[i][j][k] = i * j * k;
}
}
}
for(i = 0; i < 4; i++) {
for(j = 0; j < 5; j++) {
for(k = 0; k < 6; k++) {
System.out.print(threeD[i][j][k] + " ");
}
System.out.println();
}
System.out.println();
}
}
}