السلام عليكم
هذا البرنامج عبارة عن ضرب مصفوفتين a ,b والناتج يوضع في المصفوفة c. ويجب انه العملية الحسابية توضع في Method تسمى multiplyMatrix
حاولت في هذا البرنامج اني اقوم بضرب مصفوفتينa,b والناتج يوضع في المتغير c بس المشكلة انه المخرجات بتكون غير مش على شكل مصفوفة
هذا هو البرنامج
package secondsemesterassignment1;
public class MultiplyingTwoMatrices{
public static int[][] multiplyMatrix(int[][]a1 ,int[][]b1){
int [][]a;
int [][]b;
int [][]c;
int x,y,z;
a= new int[3][3];
b=new int[3][3];
//c= new int [][];
c= new int[a.length][b[0].length];
for(x = 0 ; x < c.length ; x++)
for(y = 0 ; y < c[0].length ; y++)
for(z = 0; z < b.length ; z++)
c[x][y]=c[x][y]+a[x][z]*b[z][y];
return c;
}//end MultiplyMatrix
public static void main(String [] args){
int [][]a ={{1,2,3},{4,5,6},{7,8,9}} ;
int [][]b ={{2,3,4},{5,6,7},{8,9,1}};
System.out.print("The multiplication of the two mitricies is "+
MultiplyingTwoMatrices.multiplyMatrix(a, b));
}//end main
}//end class