import java.io.*;
class arraytranspose
{
public static void main(String[] arg)
{
int m,n;
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
int arr[ ][ ]=new int[30][30];
try
{
System.out.print("Enter the number of row: ");
m=Integer.parseInt(in.readLine());
System.out.print("Enter the number of column: ");
n=Integer.parseInt(in.readLine());
System.out.print("Enter the value of elements of array: ");
for(int i=0;i< m;i++)
{
for(int j=0;j<n;j++)
{
arr[i][j]=Integer.parseInt(in.readLine());
}
}
System.out.println("Two dimensionl array before transpose:");
for(int i=0;i< m;i++)
{
for(int j=0;j<n;j++)
{
System.out.print(arr[i][j]+" ");
}
System.out.println();
}
System.out.println("Two dimensionl array after transpose:");
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
System.out.print(arr[j][i]+" ");
}
System.out.println();
}
}
catch(Exception e){ }
}
}