2D Array Nested Loop Traversal
What is printed when the following code segment is executed?
int[][] points = {{11, 12, 13, 14, 15},
{21, 22, 23, 24, 25},
{31, 32, 33, 34, 35},
{41, 42, 43, 44, 45}};
for (int row = 0; row < points.length; row++)
{
for (int col = points[0].length - 1; col >= row; col--)
{
System.out.print(points[row][col] + " ");
}
System.out.println();
}
A
15 14 13 12 11
25 24 23 22 21
35 34 33 32 31
45 44 43 42 41
B
15 14 13 12
25 24 23
35 34
45
C
15 14 13 12 11
25 24 23 22
35 34 33
45 44
D
11 12 13 14 15
21 22 23 24
31 32 33
41 42
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | bommasam000 | 1 | 3 | 0m 54s | 26 |
| #2 | demosolasis1 | 1 | 1 | 1m 20s | 20 |
| #3 | y.seong2027 | 1 | 1 | 2m 47s | -67 |
Items per page:
10
1 – 3 of 3
APFIVE