import java.util.*;
public class Matrixmult
{
public static void main (String [] args)
{
int [] [] a ={ {1,2,3} , {4,5,6} , {7,8,9} };
int [] [] b ={ {3,3,3} , {2,2,2} , {1,1,1} };
int m=3, n=3 , r=3;
int [] [] c = new int [m][r];
for (int i=0; i<=m-1; i++)
{ for(int j=0; j<=n-1; j++)
for(int k=0;k<=r-1;k++)
c[i][k] = c[i][k]+a[i][j]*b[j][k];
}
for (int i=0; i<=m-1; i++)
{ for(int j=0; j<=n-1; j++)
System.out.printf("%d\t",c[i][j]);
System.out.println();
}
}
}
public class Matrixmult
{
public static void main (String [] args)
{
int [] [] a ={ {1,2,3} , {4,5,6} , {7,8,9} };
int [] [] b ={ {3,3,3} , {2,2,2} , {1,1,1} };
int m=3, n=3 , r=3;
int [] [] c = new int [m][r];
for (int i=0; i<=m-1; i++)
{ for(int j=0; j<=n-1; j++)
for(int k=0;k<=r-1;k++)
c[i][k] = c[i][k]+a[i][j]*b[j][k];
}
for (int i=0; i<=m-1; i++)
{ for(int j=0; j<=n-1; j++)
System.out.printf("%d\t",c[i][j]);
System.out.println();
}
}
}
No comments:
Post a Comment
Thank You !