-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTraspose An 2D - Array(HackerEarth)
More file actions
41 lines (34 loc) · 1013 Bytes
/
Copy pathTraspose An 2D - Array(HackerEarth)
File metadata and controls
41 lines (34 loc) · 1013 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
31
32
33
34
35
36
37
38
39
40
41
package practice;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
public class rough2
{
public static void main(String args[] ) throws Exception {
//BufferedReader
Scanner sc = new Scanner(System.in);
// BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = sc.nextInt();
int M = sc.nextInt();
int[][] A = new int[N][M];
// System.out.print(A.length+"\n"+A[0].length); To find col size u have to write A[0].length
int[][] B = new int[M][N];
for(int i=0;i<N;i++)
{
for(int j=0;j<M;j++)
{
A[i][j] = sc.nextInt();
B[j][i] = A[i][j];
}
}
for(int i=0;i<M;i++)
{
for(int j=0;j<N;j++)
{
System.out.print(B[i][j]+" ");
}
System.out.println();
}
}
}