Inplace rotate square matrix by 90 degrees by forming cycles

`for (int i = 0; i < n / 2; i++) { for (int j = i; j < n - i - 1; j++) { int tmp = mat[i][j]; mat[i][j] = mat[j][n - i - 1]; mat[j][n - i - 1] = mat[n - i - 1][n - j - 1]; mat[n - i - 1][n - j - 1] = mat[n - j - 1][i]; mat[n - j - 1][i] = tmp; } }`