Page 395 - AP Computer Science A, 7th edition
P. 395

Line 10:
Line 11:
Line 12:
Line 13:
the input matrix mat is
for (int j = c; j < mat[0].length; j++)
mat[i][j] = mat[i][j+1];
//code to insert zeros in rightmost column
...
}
The intent of the method alter is to remove column c. Thus, if
2689 1543 0732
the method call alter(mat, 1) should change mat to
2890 1430 0320
The method does not work as intended. Which of the following changes will correct the problem?
Change line 10 to
I for (int j = c; j < mat[0].length – 1; j++)
and make no other changes.
Change lines 10 and 11 to
Line 14:
for (int j = c + 1; j < mat[0].length; j++) mat[i][j–1] = mat[i][j];
II
and make no other changes.
Change lines 10 and 11 to
for (int j = mat[0].length – 1; j > c; j--)










































































   393   394   395   396   397