-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArray_Transpose.java
More file actions
32 lines (29 loc) · 856 Bytes
/
Array_Transpose.java
File metadata and controls
32 lines (29 loc) · 856 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
package Arrays2D;
public class Array_Transpose {
public static void main(String[] args) {
// TODO Auto-generated method stub
int arr[][] = { { 1, 2, 3 }, { 4, 5, 6 }, { 1, 2, 3 } };
System.out.println("\nThe given Matrix: ");
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
/*
* if ((i + j) % 2 != 0) { arr[i][j] = 0; System.out.print(arr[i][j]); } else {
* System.out.print(arr[i][j]); }
*/
System.out.print(arr[i][j]);
}
System.out.println();
}
System.out.println("\nThe Transposed Matrix: ");
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
/*
* if ((i + j) % 2 != 0) { arr[i][j] = 0; System.out.print(arr[i][j]); } else {
* System.out.print(arr[i][j]); }
*/
System.out.print(arr[j][i]);
}
System.out.println();
}
}
}