testintegermatrix.java

来自「围棋的很好的程序欢迎大家来下载。初学者很有用的。」· Java 代码 · 共 35 行

JAVA
35
字号
// TestIntegerMatrix.java: Test matrix operations involving// integer valuespublic class TestIntegerMatrix {  public static void main(String[] args) {    // Create Integer arrays m1, m2    Object[][] m1 = new Integer[5][5];    Object[][] m2 = new Integer[5][5];    // Initialize Integer arrays m1 and m2    for (int i = 0; i < m1.length; i++)      for (int j = 0; j < m1[0].length; j++) {        m1[i][j] = new Integer(i);      }    for (int i = 0; i < m2.length; i++)      for (int j = 0; j < m2[0].length; j++) {        m2[i][j] = new Integer(i + j);      }    // Create instances of IntegerMatrix    IntegerMatrix im1 = new IntegerMatrix(m1);    IntegerMatrix im2 = new IntegerMatrix(m2);    // Perform integer matrix addition, and multiplication    IntegerMatrix im3 = (IntegerMatrix)im1.addMatrix(im2);    IntegerMatrix im4 = (IntegerMatrix)im1.multiplyMatrix(im2);    // Display im1, im2, im3, im4    System.out.println("m1 + m2 is ...");    GenericMatrix.printResult(im1, im2, im3, '+');    System.out.println("\nm1 * m2 is ...");    GenericMatrix.printResult(im1, im2, im4, '*');  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?