-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMatrixCategory.java
More file actions
29 lines (28 loc) · 958 Bytes
/
MatrixCategory.java
File metadata and controls
29 lines (28 loc) · 958 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
import java.io.*;
public class MatrixCategory {
public static void main() throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("ENTER THE SIZE OF MATRIX= ");
int n = Integer.parseInt(br.readLine());
int val;
int lower = 1, upper = 1;
System.out.println("ENTER THE ELEMENTS = ");
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
val = Integer.parseInt(br.readLine());
if (i > j && val != 0)
upper = 0;
if (i < j && val != 0)
lower = 0;
}
}
if (upper == 1 && lower == 1)
System.out.println("2");
else if (upper == 1)
System.out.println("1");
else if (lower == 1)
System.out.println("-1");
else
System.out.println("0");
}
}