public class matrixmultiplication
{
int a[][]={{1,2,3},{2,1,0},{0,1,2}};
int b[][]={{2,2,2},{1,0,1},{1,1,1}};
int prdt[][];
matrixmultiplication()
{
prdt=new int[3][3];
}
void findproduct()
{
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
for(int k=0;k<3;k++)
{
prdt[i][j]+=a[i][k]*b[k][j];
}
}
void product()
{
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
System.out.print(prdt[i][j]+" ");
System.out.println("\n");
}
}
void display1()
{
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
System.out.print(a[i][j]+" ");
System.out.println("\n");
}
}
void display2()
{
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
System.out.print(b[i][j]+" ");
System.out.println("\n");
}
}
public static void main(String[] args)
{
matrixmultiplication m= new matrixmultiplication();
m.display1();
System.out.println("\n");
m.display2();
m.findproduct();
System.out.println("\n");
m.product();
}
}
0 comments:
Post a Comment