Java中二维数组矩阵运算如何实现,求解答。

http://img.mukewang.com/576f4a7b0001645216000848.jpg

future_pig
浏览 1468回答 1
1回答

慕粉15160033427

package answear;public class Inter {  public static void main(String[] args) {  int[][] a = {{2,3,4},{4,6,8}};  int[][] b = {{1,5,2,8},{5,9,10,-3},{2,7,-5,-18}};  int[][] c = new int[2][4]; System.out.println("生成的新数组c是:");  for(int i=0; i<2; i++){   for(int j=0; j<4; j++){    int temp = 0;    for(int k=0; k<3; k++){     temp += a[i][k]*b[k][j];    }    c[i][j] = temp;    System.out.print(c[i][j]+" ");   }   System.out.println();  } }}
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java