#C1864. Matrix Rotation Challenge
Matrix Rotation Challenge
Matrix Rotation Challenge
You are given a square matrix of size \( n \times n \). Your task is to rotate the matrix by 90° clockwise. The rotation rule is: the element at position \( (i,j) \) moves to \( (j, n-1-i) \) for \( 0 \leq i,j < n \).
Input: The first line contains an integer \( n \) denoting the size of the matrix. The next \( n \) lines each contain \( n \) space-separated integers.
Output: Print the rotated matrix, where each row is printed on a new line and the elements are space-separated.
inputFormat
Standard input (stdin) contains the following:
- The first line contains the integer \( n \) (size of the matrix).
- The next \( n \) lines contain \( n \) space-separated integers each.
outputFormat
Standard output (stdout) should print the rotated matrix. Each line corresponds to a row of the matrix with its elements separated by a single space.
## sample3
1 2 3
4 5 6
7 8 9
7 4 1
8 5 2
9 6 3
</p>