- #1
Absolutism
- 28
- 0
Homework Statement
I am trying to rotate a 2D array of type string. I am not sure what the problem is with my function. Flipping does occur but for some reason, it's not by 90.
Homework Equations
The Attempt at a Solution
The program consists of a function and the main. Here's the code (without all the declarations in the beginning)
function:
void rotate90(string &a, string &b, string &c, string &d)
{
string temp = a;
a = b;
b = c;
c = d;
d = temp;
}
Main: (rotation + output)
for(int i=0; i<arr_row/2; i++)
for(int j=0; j<(arr_col+1)/2; j++)
rotate90(a[j], a[arr_row-1-j], a[arr_row-1-i][arr_col-1-j], a[j][arr_col-1-i]); //error is here
//output of a 90 degree rotation
cout<<"the matrix rotation"<<endl;
for (int i = 0; i< arr_row; i++) {
for (int j = 0; j< arr_col; j++) {
cout << a[j] << " ";
can someone figure out where the error is in the rotation part? Thank you