-
Notifications
You must be signed in to change notification settings - Fork 65
/
Copy pathLowerTriangularMatrix.java
62 lines (58 loc) · 970 Bytes
/
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package com.java.matrix;
/*
* Print the Lower Triangular Matrix of Given Matrix
* -------------------------------------------------
*
* say Given Matrix is
* 1 1 1
* 2 2 2
* 3 3 3
*
* Lower Triangular Matrix is
* 1
* 2 2
* 3 3 3
*
*/
public class LowerTriangularMatrix {
public static void main(String[] args) {
int matrix[][] = {
{1,1,1,1},
{2,2,2,2},
{3,3,3,3},
{4,4,4,4}
};
int rows = 4, columns = 4;
/* int matrix[][] = {
{1,1,1,1,1,1},
{2,2,2,2,2,2},
{3,3,3,3,3,3},
{4,4,4,4,4,4},
{5,5,5,5,5,5},
{6,6,6,6,6,6}
};
int rows = 6, columns = 6;*/
System.out.println("Lower Triangular Matrix is :");
for(int i=0;i<rows;i++){
for(int j=0;j<=i;j++)
System.out.print(matrix[i][j]+" ");
System.out.println();
}
}
}
/*
OUTPUT
Lower Triangular Matrix is :
1
2 2
3 3 3
4 4 4 4
OUTPUT
Lower Triangular Matrix is :
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
6 6 6 6 6 6
*/