-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtranspose.java
More file actions
30 lines (28 loc) · 953 Bytes
/
Copy pathtranspose.java
File metadata and controls
30 lines (28 loc) · 953 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
import java.util.Scanner;
class transpose {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a[][] = new int[3][3];
int b[][] = new int[3][3];
System.out.println("Enter the elements of the arrays one by one: ");
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++)
a[i][j] = sc.nextInt();
}
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++)
b[i][j] = sc.nextInt();
}
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++)
System.out.print(a[j][i]+" ");
System.out.println();
}
System.out.println();
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++)
System.out.print(b[j][i]+" ");
System.out.println();
}
}
}