import java.util.Scanner;
class Ex2DArray
{
static int i,j,n,k;
static int a[][];
public static void main (String[] args)
{
Scanner input = new Scanner(System.in);
System.out.println("Enter the number of the matrix:");
int n = input.nextInt();
a = new int [n][n];
for (i=0;i<n;i++){
for (j=0;j<n;j++){
a[i][j] = (int)(Math.random()*10);
}
}
System.out.println("Original:");
//printArray();
for (i=0;i<n;i++){
for (j=0;j<n;j++){
System.out.print(a[i][j]+" ");
}
System.out.println();
}
for (i=0;i<n;i++){
for (j=0;j<i;j++){
k = a[j][i];
a[j][i] = a[i][j];
a[i][j] = k;
}
}
System.out.println("Transpose 1:");
//printArray();
for (i=0;i<n;i++){
for (j=0;j<n;j++){
System.out.print(a[i][j]+" ");
}
System.out.println();
}
for (i=0;i<n;i++){
for (j=1;j<n;j++){
k = a[n-j-1][n-i-1];
a[n-j-1][n-i-1] = a[i][j];
a[i][j] = k;
}
}
System.out.println("Transpose 2:");
//printArray();
for (i=0;i<n;i++){
for (j=0;j<n;j++){
System.out.print(a[i][j]+" ");
}
System.out.println();
}
}
public static void printArray()
{
for (i=0;i<n;i++){
for (j=0;j<n;j++){
System.out.print(a[i][j]+" ");
}
System.out.println();
}
}
}