import java.io.*;
abstract class matrix
{
int a[][]=new int[4][4];
abstract void cal();
}
class derived extends matrix
{
int i,j,n;
public void get()
{
try
{
DataInputStream cin=new DataInputStream(System.in);
System.out.println("Enter matrix size");
n=Integer.parseInt(cin.readLine());
System.out.println("Enter the first matrix");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
a[i][j]=Integer.parseInt(cin.readLine());
}
}
}
catch(Exception e)
{
System.out.println("wrong data");
}
}
public void cal()
{
System.out.println("toriginal matrix is");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
System.out.print(""+a[i][j]);
System.out.print(" ");
}
System.out.println();
}
System.out.println("transposr of given matrix is");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
System.out.print(""+a[j][i]);
System.out.print(" ");
}
System.out.println();
}
}
}
class abs_mtr_trans
{
public static void main(String args[])
{
derived d=new derived();
d.get();
d.cal();
}
}
abstract class matrix
{
int a[][]=new int[4][4];
abstract void cal();
}
class derived extends matrix
{
int i,j,n;
public void get()
{
try
{
DataInputStream cin=new DataInputStream(System.in);
System.out.println("Enter matrix size");
n=Integer.parseInt(cin.readLine());
System.out.println("Enter the first matrix");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
a[i][j]=Integer.parseInt(cin.readLine());
}
}
}
catch(Exception e)
{
System.out.println("wrong data");
}
}
public void cal()
{
System.out.println("toriginal matrix is");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
System.out.print(""+a[i][j]);
System.out.print(" ");
}
System.out.println();
}
System.out.println("transposr of given matrix is");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
System.out.print(""+a[j][i]);
System.out.print(" ");
}
System.out.println();
}
}
}
class abs_mtr_trans
{
public static void main(String args[])
{
derived d=new derived();
d.get();
d.cal();
}
}
No comments:
Post a Comment