-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathtranspose
More file actions
29 lines (28 loc) · 842 Bytes
/
transpose
File metadata and controls
29 lines (28 loc) · 842 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
import java.util.*;
public class Transpose{
public static void main(String args []){
//
Scanner s = new Scanner(System.in);
//
int n,m;
System.out.print("enter the row of the matrix :");
n = s.nextInt();
System.out.print("enter the column of the matrix :");
m = s.nextInt();
int m1[][] = new int[n][m];
//
System.out.print("enter the elements of the matrix :");
for(int i = 0; i<n; i++){
for(int j = 0;j<m;j++){
m1[i][j] = s.nextInt();
}
}
System.out.print("transpose of the matrix is : \n");
for(int i = 0; i<n; i++){
for(int j = 0;j<m;j++){
System.out.print(m1[j][i]+"\t");
}
System.out.println();
}
}
}