#C14323. Rotate Matrix
Rotate Matrix
Rotate Matrix
Given an \(N \times N\) matrix, your task is to rotate it by 90° clockwise. The rotation is defined by the formula \(R[j][N-1-i] = M[i][j]\), where \(M\) is the original matrix and \(R\) is the rotated matrix.
If the input matrix is not a valid square matrix or is empty, output "ERROR".
inputFormat
The input is given via standard input. The first line contains an integer (N) denoting the size of the matrix. The following (N) lines each contain (N) space-separated integers representing the rows of the matrix.
outputFormat
If the matrix is a valid (N \times N) matrix, output the rotated matrix via standard output, with each row printed on a new line and the elements separated by a single space. Otherwise, output "ERROR".## sample
3
1 2 3
4 5 6
7 8 9
7 4 1
8 5 2
9 6 3
</p>