-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathLowerTriangularMatrix.java
41 lines (36 loc) · 1.1 KB
/
LowerTriangularMatrix.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
public class LowerTriangular
{
public static void main(String[] args) {
int row, col;
int rawMatrix[][] = {
{5, 6, 7},
{8, 7, 4},
{1, 6, 2}
};
row = rawMatrix.length;
col = rawMatrix[0].length;
if(row != col){
System.out.println("This is not a square Matrix , Try Again !!!");
}
else {
System.out.println("Raw Matrix >>> ");
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
System.out.print(rawMatrix[i][j]+" ");
}
System.out.println();
}
System.out.println();
System.out.println("Lower Triangular matrix >>> ");
for(int i = 0; i < row; i++){
for(int j = 0; j < col; j++){
if(j > i)
System.out.print("0 ");
else
System.out.print(rawMatrix[i][j] + " ");
}
System.out.println();
}
}
}
}