public class RotateParameters
{
public string[,] OriginalArray { get; set; }
public int RotationChoice { get; set; }
}
public class PatternnaDrawnaDrawnaDraw
{
// ... ส่วนอื่น ๆ ในคลาส PatternnaDrawnaDrawnaDraw ...
public string[,] RotateArray(RotateParameters parameters)
{
string[,] original = parameters.OriginalArray;
int rotationChoice = parameters.RotationChoice;
int rows = original.GetLength(0);
int cols = original.GetLength(1);
string[,] rotated = new string[cols, rows];
switch (rotationChoice)
{
case 0: // 0 degrees (no rotation)
rotated = (string[,])original.Clone();
break;
case 1: // 90 degrees clockwise
for (int i = 0; i < rows; i++)
{
for (int j = 0; j < cols; j++)
{
rotated[j, rows - 1 - i] = original[i, j];
}
}
break;
case 2: // 180 degrees clockwise
for (int i = 0; i < rows; i++)
{
for (int j = 0; j < cols; j++)
{
rotated[rows - 1 - i, cols - 1 - j] = original[i, j];
}
}
break;
case 3: // 270 degrees clockwise
for (int i = 0; i < rows; i++)
{
for (int j = 0; j < cols; j++)
{
rotated[cols - 1 - j, i] = original[i, j];
}
}
break;
}
return rotated;
}
// ... ส่วนอื่น ๆ ในคลาส PatternnaDrawnaDrawnaDraw ...
}