CODE:
import java.util.*;
class Transpose1
{
public static void
main(String args[])
{
int m,i,j,temp;
Scanner sc = new
Scanner(System.in);
System.out.print("Enter
value for m :");
m=sc.nextInt();
int a[][]=new
int[m][m];
System.out.println("Matrix
A");
for(i=0;i<=m-1;i++)
{
for(j=0;j<=n-1;j++)
{
System.out.print("enter
a no:");
a[i][j]=sc.nextInt();
}
}
for(i=0;i<=m-1;i++)
{
for(j=0;j<=n-1;j++)
{
temp=a[i][j];
a[i][j]=a[j][i];
a[j][i]=temp;
}
}
System.out.println("Transpose
Matrix");
for(i=0;i<=m-1;i++)
{
for(j=0;j<=n-1;j++)
{
System.out.print(a[i][j]+"/t");
}
System.out.println();
}
}
}
OUTPUT:
No comments :
Post a Comment