i`ve spent hours writing and ammending this rotate() function to no avail. So now i`ve obtained the correct function from the author which works. I can still not understand how the logic was arrived at. I have traced the function call and of course it works. I have looked for patterns to see how they are reflected in the function again to no avail. i cannot see the logic of how the rows are being transformed into columns or the logic of how the individual elements are being repositioned in the temp array

The matrix is presented in main() as a one dimensional array which is printed out as a square matrix of 3 rows and 3 columns using the print () function which i understand.

Here are the 2 functions with my 2 commented questions

[code]void rotate (Matrix m)

{Matrix temp;//

**1.How is this declaration legal without the [ ]?**

for(int i=0;i<SIZE;i++)

for(int j=0;j<SIZE;j++)

temp[i][j]=m[SIZE-j-1][i];//

**2.This is the purplexing line, what is its logic?**

for(int i=0;i<SIZE;i++)

for(int j=0;j<SIZE;j++)

m[i][j]= temp [i][j];

}

void print (Matrix a)

{

for(int i=0;i<SIZE;i++)

{

for(int j=0;j<SIZE;j++)

cout<<a[i][j]<<"\t";

cout<<endl;

}

cout<<endl ;}[/CODE ]

This is the before and after output

/*Original square matrix:

11 22 33

44 55 66

77 88 99

Matrix now rotated 90

77 44 11

88 55 22

99 66 33*/

I would appreciate some enlightenment in due course when time allows.