# 求这道题该怎么解？求各位大神给个详细思路

neal2004 发布于 2013/05/16 22:56

a11 a12... a1n

a21 a22... a2n
... ... ...

am1 am2... amn

a11 a12 a13

a21 a22 a23

b11 b12

b21 b22

b31 b32

a和b可以相乘，乘积矩阵为：

a11*b11+a12*b21+a13*b31    a11*b12+a12*b22+a13*b3
a21*b11+a22*b21+a23*b31    a21*b12+a22*b22+a23*b32

Matrix类的定义如下：
public class Matrix {
private double[][] data;
private int rows;
private int cols;
public Matrix(int rows, int cols) {
if (rows <= 0 || cols <= 0)
throw new IllegalArgumentException(");
this.rows = rows;
this.cols = cols;
data = new double[rows][cols];
}
public Matrix(int rows, int cols, String line) {
if (rows <= 0 || cols <= 0 || line == null)
throw new IllegalArgumentException("");
String[] dataStr = line.split(",");
if (  空白处1  ) {
throw new IllegalArgumentException("");
}
this.rows = rows;
this.cols = cols;
data = new double[rows][cols];
for (int i = 0; i < dataStr.length; i++) {
空白处2
}
}
public Matrix mul(Matrix ma) {
if (          空白处3          ) {
throw new IllegalArgumentException("");
}
Matrix mc = new Matrix(rows, ma.cols);
for (int i = 0; i < mc.getRows(); i++) {
for (int j = 0; j < mc.getCols(); j++) {
for (          空白处4          ) {
空白处5
}
}
}
return mc;
}
public int getRows() {
return rows;
}
public int getCols() {
return cols;
}
public String toString() {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols - 1; j++) {
sb.append(data[i][j]).append(",");
}
sb.append(data[i][cols - 1]).append("\n");
}
return sb.toString();
}
}

A. dataStr.length != (rows-1) * (cols-1)
B. dataStr.length != (rows-1) * cols
C. dataStr.length != rows * cols
D. dataStr.length != rows * (cols-1)

37. 下列选项中，能填入空白处2的代码是(    )
A. data[i % cols][i / cols] = Double.parseDouble(dataStr[i]);
B. data[i/cols][i % cols] = Double.parseDouble(dataStr[i]);
C. data[i/ rows][i % rows] = Double.parseDouble(dataStr[i]);
D. data[i % rows][i /rows] = Double.parseDouble(dataStr[i]);

38. 下列选项中，能填入空白处3的代码是(    )
A. cols != ma.cols
B. rows != ma.cols
C. rows != ma.rows
D. cols != ma.rows

39. 下列选项中，能填入空白处4的代码是(    )
A. int k = 0; k < cols; k++
B. int k = 0; k <ma.cols; k++
C. int k = 0; k <rows; k++
D. int k = 0; k <rows * ma.cols; k++

40. 下列选项中，能填入空白处5的代码是(    )
A. mc.data[i][j] += data[k][j] * ma.data[i][k];
B. mc.data[i][j] += data[k][i] * ma.data[j][k];
C. mc.data[i][j] += data[j][k] * ma.data[k][i];
D. mc.data[i][j] += data[i][k] * ma.data[k][j];

0

0

045public Matrix(int rows, int cols, String line) {

0