class s02_01
{
public static void main(String arg[])
{
int a[][]=new int[3][3];
int b[][]=new int[3][3];
int c[][]=new int[3][3];
int n=0;
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
a[i][j]=Integer.parseInt(arg[n++]);
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
b[i][j]=Integer.parseInt(arg[n++]);
//multipying the two matrix
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
{
c[i][j]=0;
for(int k=0;k<3;k++)
c[i][j]+=(a[i][k]*b[k][j]);
}
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
System.out.print(c[i][j]+" ");
System.out.println();
}
}
}
{
public static void main(String arg[])
{
int a[][]=new int[3][3];
int b[][]=new int[3][3];
int c[][]=new int[3][3];
int n=0;
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
a[i][j]=Integer.parseInt(arg[n++]);
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
b[i][j]=Integer.parseInt(arg[n++]);
//multipying the two matrix
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
{
c[i][j]=0;
for(int k=0;k<3;k++)
c[i][j]+=(a[i][k]*b[k][j]);
}
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
System.out.print(c[i][j]+" ");
System.out.println();
}
}
}
No comments:
Post a Comment