-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMatrixTrans.java
More file actions
42 lines (39 loc) · 914 Bytes
/
Copy pathMatrixTrans.java
File metadata and controls
42 lines (39 loc) · 914 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
30
31
32
33
34
35
36
37
38
39
40
41
42
package day24;
import java.util.*;
public class MatrixTrans {
public static void main(String[] args) {
int a[][]= {{1,2,3},{4,5,6},{9,8,7}};
int b[][]= {{1,1,1},{1,1,1},{1,1,1}};
int c[][]=new int[3][3];
int d[][]=new int[3][3];
for(int i=0;i<a.length;i++) {
for(int j=0;j<a.length;j++) {
System.out.print(a[j][i]+" ");
}
System.out.println();
}
for(int i=0;i<a.length;i++) {
for(int j=0;j<a.length;j++) {
if(i==j) {
System.out.println(a[i][j]);
}
}
}
//lower triangle
System.out.println("lower triangle");
for(int i=0;i<a.length;i++) {
for(int j=0;j<=i;j++) {
System.out.print(a[i][j]+" ");
}
System.out.println();
}
//upper triangle triangle
System.out.println("upper triangle");
for(int i=0;i<a.length;i++) {
for(int j=i;j<a.length;j++) {
System.out.print(a[i][j]+" ");
}
System.out.println();
}
}
}