?

Free Version
Difficult

# Manipulating 2-D Arrays

APCSA-LMVKBZ

The following method takes a two-dimensional array a and returns a two-dimensional array b made by rotating a by 90° counterclockwise.

 public static int[][] rotate(int[][]a)
{
int rows = a.length;
int cols = a[0].length;
int[][] b = new int[cols][rows];

for (int r = 0; r < rows; r++)
for (int c = 0; c < cols; c++)
b[c][r] = <Expression 1>;

return b;
}


For example, if a holds
1 2 3
4 5 6

b = rotate(a) will hold

3 6
2 5
1 4

Which of the following should replace Expression 1?

A

a[rows - 1 - r][c]

B

a[r][c]

C

a[c][r]

D

a[r][cols - 1 - c]

E

a[rows - 1 - r][cols - 1 - c]