1.6 Given an image represented by an N*N matrix,where each pixel in the image is 4 bytes,
writea method to rotate the image by 90 degrees. Can you do this in place?
Answer:
顺时针旋转
void rotation(int matrix[][],int n,int n)
{
if (matrix = NULL)
return;
int i,j;
for (i=1;i<=n;i++)
{
for (j=1;j<=n;j++)
{
swap(matrix[i][j],matrix[j][n-i+1]);
}
}
}