-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLowerTriangleMatrix.java
More file actions
34 lines (33 loc) · 1.18 KB
/
LowerTriangleMatrix.java
File metadata and controls
34 lines (33 loc) · 1.18 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
import java.io.*;
public class LowerTriangleMatrix {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("ENTER THE NUMBER OF ROWS =");
int m = Integer.parseInt(br.readLine());
System.out.println("ENTER THE NUMBER OF COLUMNS =");
int n = Integer.parseInt(br.readLine());
int arr[][] = new int[m][n];
System.out.println("ENTER THE ELEMENTS=");
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
arr[i][j] = Integer.parseInt(br.readLine());
}
}
System.out.println("MATRIX IS=");
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
System.out.print(arr[i][j] + " ");
}
System.out.println();
}
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
if (i < j) {
System.out.print(" " + " ");
} else
System.out.print(arr[i][j] + " ");
}
System.out.println();
}
}
}