-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtranspose.java
39 lines (35 loc) · 936 Bytes
/
transpose.java
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
import java.util.*;
class transpose
{
public static void main(String args[])
{
Scanner obj = new Scanner(System.in);
System.out.println("how many row");
int r = obj.nextInt();
System.out.println("how many coln");
int c = obj.nextInt();
int a[][] = new int[10][10];
int t[][] = new int[10][10];
System.out.println("enter the elements into the array");
for(int i=0;i<r;i++)
for(int j=0;j<c;j++)
a[i][j] = obj.nextInt();
System.out.println("matrix a");
for(int i=0;i<r;i++)
{
System.out.println();
for(int j=0;j<c;j++)
System.out.print(a[i][j]+" ");
}
for(int i=0;i<r;i++)
for(int j=0;j<c;j++)
t[j][i]=a[i][j];
System.out.println("transpose of matrix a is");
for(int i=0;i<r;i++)
{
System.out.println();
for(int j=0;j<c;j++)
System.out.print(t[i][j]+" ");
}
}
}