-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathfourDarray.java
53 lines (52 loc) · 1.49 KB
/
fourDarray.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
47
48
49
50
51
52
53
import java.util.*;
public class fourDarray
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
int number=0;
System.out.println("Enter the number of blocks");
number = in.nextInt();
int l; //length
int b; //breadth
int h; //height
System.out.println("Enter the length breadth and height of the array");
l = in.nextInt();
b = in.nextInt();
h = in.nextInt();
int[][][][] arr = new int[number][l][b][h];
for(int i=0;i<number;i++)
{
System.out.println("Enter the "+i+" 3d array elements");
for(int j=0;j<l;j++)
{
for(int k=0;k<b;k++)
{
for(int m=0;m<h;m++)
{
arr[i][j][k][m] = in.nextInt();
}
}
}
}
//printing
for(int i=0;i<number;i++)
{
System.out.println("The "+i+" 3d array elements are:");
for(int j=0;j<l;j++)
{
for(int k=0;k<b;k++)
{
for(int m=0;m<h;m++)
{
System.out.print( arr[i][j][k][m]+ " ");
}
System.out.println();
}
System.out.println("-------");
}
System.out.println("******************");
}
in.close();
}
}