rotating a 2D array
in
Programming Questions
•
2 years ago
Hi
Does a simple way of rotating the components of a 2D array exist?
Like taking this array:
int[][] original = {{ 0, 1, 0 },
{ 1, 0, 1 },
{ 0, 0, 0 }};
... and changing it to this:
int[][] cw90 = {{ 0, 1, 0 },
{ 0, 0, 1 },
{ 0, 1, 0 }};
Does a simple way of rotating the components of a 2D array exist?
Like taking this array:
int[][] original = {{ 0, 1, 0 },
{ 1, 0, 1 },
{ 0, 0, 0 }};
... and changing it to this:
int[][] cw90 = {{ 0, 1, 0 },
{ 0, 0, 1 },
{ 0, 1, 0 }};
1