// Program
import
java.util.Scanner;
public
class Matrix_Transpose
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int a[][]=new int[10][10];
System.out.println("Rows");
int r=sc.nextInt();
System.out.println("Columns");
int c=sc.nextInt();
System.out.println("Enter elements
for Matrix");
for(int i=1;i<=r;i++)
{
for(int j=1;j<=c;j++)
{
a[i][j]=sc.nextInt();
}
}
System.out.println("Matrix
is");
for(int i=1;i<=r;i++)
{
for(int j=1;j<=c;j++)
{
System.out.print("\t"+a[i][j]);
}
System.out.print("\n");
}
System.out.println("Transpose of
the matrix is");
for(int i=1;i<=c;i++)
{
for(int j=1;j<=r;j++)
{
System.out.print("\t"+a[j][i]);
}
System.out.print("\n");
}
}
}
No comments:
Post a Comment
Note: only a member of this blog may post a comment.