-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTranspose.java
More file actions
58 lines (58 loc) · 1.27 KB
/
Copy pathTranspose.java
File metadata and controls
58 lines (58 loc) · 1.27 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import java.util.Scanner;
class Transpose
{
public static void main(String args[])
{
Transpose obj=new Transpose(); obj.accept();
obj.find_transpose();
obj.print();
}
int a[][],t[][],n,m;
Transpose()
{
n=0;
m=0;
}
Transpose(int u,int v)
{
m=u;
n=u;
}
void accept()
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the size of the Squate matrix");
n=sc.nextInt();
m=n;
a=new int[m][n];
t=new int[m][n];
System.out.println("Enter the elements");
for(int i=0;i<m;i++)
for(int j=0;j<n;j++)
a[i][j]=sc.nextInt();
}
void find_transpose()
{
for(int i=0;i<m;i++)
for(int j=0;j<n;j++)
t[j][i]=a[i][j];
}
void print()
{
int flag=0;
System.out.println("The source array:");
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
System.out.print(a[i][j]);
System.out.println();
}
System.out.println("The transpose array:");
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
System.out.print(t[i][j]);
System.out.println();
}
}
}