using System;
public class HelloWorld
{
public static void ShowMap(int [,] map)
{
int rows = map.GetLength(0);
int cols = map.GetLength(1);
if(rows<=0 || cols<=0) return;
for(int r =0;r<rows;r++)
{
for(int c=0;c<cols;c++)
{
Console.Write($"{map[r,c]}");
}
Console.WriteLine("");
}
}
public static int [,] Rotate(int [,] map)
{
int rows = map.GetLength(0);
int cols = map.GetLength(1);
int [,] newMap = new int[cols,rows];
for(int x=0;x<cols;x++)
{
for(int y=0;y<rows;y++)
{
newMap[x, rows-y-1] = map[y,x];
}
}
return newMap;
}
public static void Main()
{
int [,] map = new int[4,5] {
{0,1,0,0,0},
{0,1,0,0,0},
{0,1,1,0,0},
{0,1,1,1,0},
};
Console.WriteLine("HELLO world! - cs.jsrun.net ");
Console.WriteLine("Rotate 0:");
ShowMap(map);
int [,] newMap = Rotate(map);
Console.WriteLine("Rotate 90:");
ShowMap(newMap);
int [,] newMap2 = Rotate(newMap);
Console.WriteLine("Rotate 180:");
ShowMap(newMap2);
int [,] newMap3 = Rotate(newMap2);
Console.WriteLine("Rotate 270:");
ShowMap(newMap3);
}
}