熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> Java核心技術 >> 正文

用Java的循環實現矩陣乘法代碼分享

2022-06-13   來源: Java核心技術 

  public class MultiMatrix {
  int[][] multiplyMatrix;
  public static void main(String args[]){
  int[][] a={{}{}};
  int[][] b={{}{}{}{}};
  MultiMatrix mm=new MultiMatrix();
  mmmMatrix(ab);
  mmdisplay();
  
  }
  public void mMatrix(int[][] aint[][] b){
  multiplyMatrix=new int[alength][b[]length];
  for (int i = ; i<alength; i++) {//rows of a
  for (int j = ; j<b[]length; j++) {//columns of b
  for (int k = ; k<a[]length; k++) {//columns of a = rows of b
  multiplyMatrix[i][j]=multiplyMatrix[i][j]+a[i][k]*b[k][j];
  }
  }
  }
  }
  public void display(){
  for (int i = ; i<multiplyMatrixlength; i++) {
  for (int j = ; j<multiplyMatrix[]length; j++) {
  Systemoutprint (multiplyMatrix[i][j]+ );
  
  }
  Systemoutprintln ();
  }
  }
  }
  

From:http://tw.wingwit.com/Article/program/Java/hx/201311/25688.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.