n == matrix.length == matrix[i].length
1 <= n <= 20
-1000 <= matrix[i][j] <= 1000
public class Solution {
public void Rotate(int[][] matrix) {
int n = matrix.Length;
// 首先进行上下翻转
for (int i = 0; i < n / 2; i++)
{
// 交换上下行
int[] temp = matrix[i];
matrix[i] = matrix[n - i - 1];
matrix[n - i - 1] = temp;
}
// 然后进行对角线翻转
for (int i = 0; i < n; i++)
{
for (int j = i; j < n; j++)
{
// 交换对角线元素
int temp = matrix[i][j];
matrix[i][j] = matrix[j][i];
matrix[j][i] = temp;
}
}
}
}