-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMaxNum3d.java
More file actions
43 lines (31 loc) · 1.11 KB
/
Copy pathMaxNum3d.java
File metadata and controls
43 lines (31 loc) · 1.11 KB
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
import java.util.Scanner;
public class MaxNum3d {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter the num. of rows : ");
int a = sc.nextInt();
System.out.print("Enter the num. of Column : ");
int b = sc.nextInt();
System.out.print("Enter the third dimension : ");
int c = sc.nextInt();
int[][][] arr = new int[a][b][c];
for (int i = 0; i < arr.length; i++) {
for (int j = 0; j < arr[i].length; j++) {
for (int k = 0; k < arr[i][j].length; k++) {
arr[i][j][k] = sc.nextInt();
}
}
}
int max = arr[0][0][0];
for (int i = 0; i < arr.length; i++) {
for (int j = 0; j < arr[i].length; j++) {
for (int k = 0; k < arr[i][j].length; k++) {
if (arr[i][j][k] > max) {
max = arr[i][j][k];
}
}
}
}
System.out.println("Minimum num in the array is : " + max);
}
}