Hello Guys,
If I rotate 2D array anticlockwise,h ow would I map original variables into new matrix?
Consider the example:
original matrix =
1 2 3
4 5 6
7 8 9
Final matrix =
3 6 9
2 5 8
1 4 7
Now If I want to access the 6 from original matrix.I'd use..
i = 1 and j =2..i.e. OriginalArr[i][j] will give me 6.
My question is, how could I access same number(here 6) from final matrix using previous i and j ?
One solution could be FinalnalArr[ i -1 ] [ j -1 ]
but this is not generalized.
I want general solution that work for any i,j as well as for any 2D matrix(any dimensions).
If I rotate 2D array anticlockwise,h ow would I map original variables into new matrix?
Consider the example:
original matrix =
1 2 3
4 5 6
7 8 9
Final matrix =
3 6 9
2 5 8
1 4 7
Now If I want to access the 6 from original matrix.I'd use..
i = 1 and j =2..i.e. OriginalArr[i][j] will give me 6.
My question is, how could I access same number(here 6) from final matrix using previous i and j ?
One solution could be FinalnalArr[ i -1 ] [ j -1 ]
but this is not generalized.
I want general solution that work for any i,j as well as for any 2D matrix(any dimensions).
Comment