Here it is in C#
int[,] array =newint[4,4]{{1,2,3,4},{5,6,7,8},{9,0,1,2},{3,4,5,6}};int[,] rotated =RotateMatrix(array,4);staticint[,]RotateMatrix(int[,] matrix,int n){int[,] ret =newint[n, n];for(int i =0; i < n;++i){for(int j =0; j < n;++j){
ret[i, j]= matrix[n - j -1, i];}}return ret;}