class Program
{
int painter = 0;
int upDown = 0;
int leftRight = 0;
int paintLength = 0;
int whereToGo = 1;
int whereToTurn = 0;
private void GetWhere()
{
if (whereToTurn == 0 && whereToGo > 1)
{
whereToGo--;
}
else if (whereToTurn == 0 && whereToGo == 1)
{
whereToGo = 4;
}
if (whereToTurn == 1 && whereToGo == 3)
{
whereToGo = 4;
}
else if (whereToTurn == 1 && whereToGo != 3)
{
whereToGo = (whereToGo + 1) % 4;
}
}
private void paint( int where, int length, int[,] myPaint)
{
if (where == 1)
{
for ( int i = 0; i < length; i++)
{
myPaint.SetValue(1, i + leftRight, upDown);
}
leftRight = leftRight + length;
}
if (where == 2)
{
for ( int i = 0; i < length; i++)
{
myPaint.SetValue(1, leftRight, i + upDown);
}
upDown = upDown + length;
}
if (where == 3)
{
for ( int i = 0; i < length; i++)
{
myPaint.SetValue(1, leftRight - i, upDown);
}
leftRight = leftRight - length;
}
if (where == 4)
{
for ( int i = 0; i < length; i++)
{
myPaint.SetValue(1, leftRight, upDown - i);
}
upDown = upDown - length;
}
}
static void Main( string[] args)
{
Program d = new Program();
int[,] myPaint = new int[20, 20];
for ( int i = 0; i < 20; i++)
{
for ( int j = 0; j < 20; j++)
{
myPaint.SetValue(0, i, j);
}
}
while ( true)
{
Console.WriteLine( "请输入指令");
string zhiling = Console.ReadLine();
if (zhiling == "1")
{
d.painter = 0;
}
if (zhiling == "2")
{
d.painter = 1;
}
if (zhiling == "3")
{
d.whereToTurn = 1;
d.GetWhere();
}
if (zhiling == "4")
{
d.whereToTurn = 0;
d.GetWhere();
}
if (zhiling.IndexOf(',') >= 1)
{
string temp = "";
CharEnumerator charZhiling = zhiling.GetEnumerator();
charZhiling.MoveNext();
charZhiling.MoveNext();
for ( int i = 0; i < zhiling.Length - 2; i++)
{
charZhiling.MoveNext();
temp = temp + charZhiling.Current.ToString();
}
d.paintLength = Int32.Parse(temp);
d.paint(d.whereToGo, d.paintLength, myPaint);
}
if (zhiling == "6")
{
for ( int i = 0; i < 20; i++)
{
for ( int j = 0; j < 20; j++)
{
if (j < 19)
{
Console.Write(myPaint.GetValue(j, i));
}
if (j == 19)
{
Console.WriteLine(myPaint.GetValue(j, i));
}
}
}
}
}
}
}