-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLargestNum_2DArray.java
More file actions
40 lines (37 loc) · 1.01 KB
/
LargestNum_2DArray.java
File metadata and controls
40 lines (37 loc) · 1.01 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
package Arrays2D;
import java.util.Scanner;
public class LargestNum_2DArray {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
System.out.println("Enter the input elements of the array: ");
int arr[][] = new int[4][4];
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
arr[i][j] = sc.nextInt();
}
System.out.println();
}
System.out.println("The Output matrix is: ");
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
System.out.print(arr[i][j]);
}
System.out.println();
}
System.out.println("\nThe Output matrix of largest number is: ");
for (int i = 0; i < 4;) {
for (int j = 0; j < 4; j++) {
System.out.println("\nThe largest number in row" + " " + (i + 1) + ":");
if (arr[i][j] > arr[i][j]) {
System.out.println(arr[i][j]);
i++;
} else {
System.out.println(arr[i][j]);
}
}
System.out.println();
}
sc.close();
}
}