-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLowerTriangleMatrixWithTemp.java
More file actions
36 lines (35 loc) · 1.24 KB
/
LowerTriangleMatrixWithTemp.java
File metadata and controls
36 lines (35 loc) · 1.24 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
import java.io.*;
public class LowerTriangleMatrixWithTemp {
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++) {
int temp = arr[i][j];
if (i < j) {
System.out.print(" " + " ");
} else {
System.out.print(temp + " ");
}
}
System.out.println();
}
}
}