-
Notifications
You must be signed in to change notification settings - Fork 243
/
transpose.java
41 lines (39 loc) · 961 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
40
41
import java.util.*;
class transpose
{
public static void main(String args[])
{
int i,j;
int a[][]=new int[20][20];
int t[][]=new int[20][20];
Scanner sc=new Scanner(System.in);
System.out.println("enter numbr of rows:");
int m=sc.nextInt();
System.out.println("enter number of cloumns:");
int n=sc.nextInt();
System.out.println("enter the matrix:");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
a[i][j]=sc.nextInt();
}
}
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
t[i][j]=a[j][i];
}
}
System.out.println("transpose is:");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
System.out.println(t[i][j]+"\t");
}
}
System.out.println("\n");
}
}