Write a java program to display the product of two given matrices
public class Matrix
{
public static void main(String args[])
{
int a[][] ={{ 1, 2, 5 },{ 3, 4, 4 },{ 5, 6, 2 },};
int b[][] ={{ 7, 8, 9 },{ 1, 2, 3 },{ 4, 9, 5 },};
int c[][] = mult(a, b);
System.out.println("Result: ");
for (int i = 0; i < c.length; ++i)
{
System.out.print("{");
for (int j = 0; j < c.length; ++j)
{
System.out.print(" "+c[j]);
}
System.out.println("}");
}
}
public static int mult(int a[][], int b[][])[][]
{
int rows = a.length;
int cols = b[0].length;
int c[][] = new int[rows][cols];
for (int i = 0; i <>
{
for (int j = 0; j <>
{
c[j] = 0;
for (int k = 0; k <>
{
c[j]= a[k] * b[k][j]+c[j];
}
}
}
return c;
}
}
Wednesday, January 23, 2008
Write a java program to display the product of two given matrices
Posted by Blogger 2.o at 11:43 PM
Labels: 2008, BLUEJ, computer icse, computer program, for icse students, icse, JAVA program, matrix multiplication, model test paper, Questions, Tests
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment