import java.util.Scanner;
public class Transpose
{
public static void main(String args[])
{
int i, j n,m;
int arr[][] = new int[10][10];
int Tran[][] = new int[10][10];
Scanner sc = new Scanner(System.in);
System.out.print("Enter no of rows and columns : ");
n=sc.nextInt();
m=sc.nextint();
for(i=0; i<n; i++)
{
for(j=0; j<m; j++)
{
arr[i][j] = sc.nextInt();
}
}
System.out.print("Transposing Array...\n");
for(i=0; i<n; i++)
{
for(j=0; j<m; j++)
{
Tran[i][j] = arr[j][i];
}
}
System.out.print("Transpose of the Matrix is :\n");
for(i=0; i<n; i++)
{
for(j=0; j<m; j++)
{
System.out.print(Tran[i][j]+ " ");
}
System.out.println();
}
}
}
public class Transpose
{
public static void main(String args[])
{
int i, j n,m;
int arr[][] = new int[10][10];
int Tran[][] = new int[10][10];
Scanner sc = new Scanner(System.in);
System.out.print("Enter no of rows and columns : ");
n=sc.nextInt();
m=sc.nextint();
for(i=0; i<n; i++)
{
for(j=0; j<m; j++)
{
arr[i][j] = sc.nextInt();
}
}
System.out.print("Transposing Array...\n");
for(i=0; i<n; i++)
{
for(j=0; j<m; j++)
{
Tran[i][j] = arr[j][i];
}
}
System.out.print("Transpose of the Matrix is :\n");
for(i=0; i<n; i++)
{
for(j=0; j<m; j++)
{
System.out.print(Tran[i][j]+ " ");
}
System.out.println();
}
}
}
No comments:
Post a Comment