Ok heres my problem i need to take a matrix like these below and rotate the numbers.... How might i do this ?? i figure the code would have 4 for loops and each one would change the row and cololum of each varible.
Here is an example Matrix:
123
456
789
And this is what I want to do....
412
753
896
I have another question but until i find that i can do this one I will not post it..Code:void Array2::rotate() { int temp; for(int r=0; r < n; r++) { for(int c=c-1; c<n; c++) { temp=A[r][c]; A[r][c]=A[c][r]; A[c][r]= temp; } for(int r=r+1; r< n; r++) { temp=A[c][r]; A[r][c]=A[c][r]; A[r][c]=temp; } for(int c=r; c<n; c++) { temp=A[c][r]; A[r][c]=A[c][r]; A[r][c]=temp; } for(int r=c; r<n; r++) { temp=A[c][r]; A[r][c]=A[c][r]; A[r][c]=temp; } }
Any help would be appreciated....
Thanks Achilles