看起来有点长,其实算法很简单,我也期望有高手能写出更简洁的代码:
static void Main(string[] args)
{
int[,] arr0 ={
{0,1,1,1,0},{1,0,0,0,1},{1,0,0,0,1},{1,0,0,0,1},{0,0,0,0,0},{1,0,0,0,1},{1,0,0,0,1},{1,0,0,0,1},{0,1,1,1,0}
};
int[,] arr1 ={
{0,0,0,0,0},{0,0,0,0,1},{0,0,0,0,1},{0,0,0,0,1},{0,0,0,0,0},{0,0,0,0,1},{0,0,0,0,1},{0,0,0,0,1},{0,0,0,0,0}
};
int[,] arr2 ={
{0,1,1,1,0},{0,0,0,0,1},{0,0,0,0,1},{0,0,0,0,1},{0,1,1,1,0},{1,0,0,0,0},{1,0,0,0,0},{1,0,0,0,0},{0,1,1,1,0}
};
int[,] arr3 ={
{0,1,1,1,0},{0,0,0,0,1},{0,0,0,0,1},{0,0,0,0,1},{0,1,1,1,0},{0,0,0,0,1},{0,0,0,0,1},{0,0,0,0,1},{0,1,1,1,0}
};
int[,] arr4 ={
{0,0,0,0,0},{1,0,0,0,1},{1,0,0,0,1},{1,0,0,0,1},{0,1,1,1,0},{0,0,0,0,1},{0,0,0,0,1},{0,0,0,0,1},{0,0,0,0,0}
};
int[,] arr5 ={
{0,1,1,1,0},{1,0,0,0,0},{1,0,0,0,0},{1,0,0,0,0},{0,1,1,1,0},{0,0,0,0,1},{0,0,0,0,1},{0,0,0,0,1},{0,1,1,1,0}
};
int[,] arr6 ={
{0,1,1,1,0},{1,0,0,0,0},{1,0,0,0,0},{1,0,0,0,0},{0,1,1,1,0},{1,0,0,0,1},{1,0,0,0,1},{1,0,0,0,1},{0,1,1,1,0}
};
int[,] arr7 ={
{0,1,1,1,0},{0,0,0,0,1},{0,0,0,0,1},{0,0,0,0,1},{0,0,0,0,0},{0,0,0,0,1},{0,0,0,0,1},{0,0,0,0,1},{0,0,0,0,0}
};
int[,] arr8 ={
{0,1,1,1,0},{1,0,0,0,1},{1,0,0,0,1},{1,0,0,0,1},{0,1,1,1,0},{1,0,0,0,1},{1,0,0,0,1},{1,0,0,0,1},{0,1,1,1,0}
};
int[,] arr9 ={
{0,1,1,1,0},{1,0,0,0,1},{1,0,0,0,1},{1,0,0,0,1},{0,1,1,1,0},{0,0,0,0,1},{0,0,0,0,1},{0,0,0,0,1},{0,1,1,1,0}
};
string value= Console.ReadLine();
for (int m=0; m < 9;m++ )
{
for (int i =0; i < value.Length; i++)
{
switch (value[i])
{
case '0':
for (int k = 0; k < 5; k++)
{
if (arr0[m,k] == 1)
Console.Write("#");
else
Console.Write(" ");
}
Console.Write("\t");
break;
case '1':
for (int k = 0; k < 5; k++)
{
if (arr1[m,k] == 1)
Console.Write("#");
else
Console.Write(" ");
}
Console.Write("\t");
break;
case '2':
for (int k = 0; k < 5; k++)
{
if (arr2[m,k] == 1)
Console.Write("#");
else
Console.Write(" ");
}
Console.Write("\t");
break;
case '3':
for (int k = 0; k < 5; k++)
{
if (arr3[m,k] == 1)
Console.Write("#");
else
Console.Write(" ");
}
Console.Write("\t");
break;
case '4':
for (int k = 0; k < 5; k++)
{
if (arr4[m,k] == 1)
Console.Write("#");
else
Console.Write(" ");
}
Console.Write("\t");
break;
case '5':
for (int k = 0; k < 5; k++)
{
if (arr5[m,k] == 1)
Console.Write("#");
else
Console.Write(" ");
}
Console.Write("\t");
break;
case '6':
for (int k = 0; k < 5; k++)
{
if (arr6[m,k] == 1)
Console.Write("#");
else
Console.Write(" ");
}
Console.Write("\t");
break;
case '7':
for (int k = 0; k < 5; k++)
{
if (arr7[m,k] == 1)
Console.Write("#");
else
Console.Write(" ");
}
Console.Write("\t");
break;
case '8':
for (int k = 0; k < 5; k++)
{
if (arr8[m,k] == 1)
Console.Write("#");
else
Console.Write(" ");
}
Console.Write("\t");
break;
case '9':
for (int k = 0; k < 5; k++)
{
if (arr9[m,k] == 1)
Console.Write("#");
else
Console.Write(" ");
}
Console.Write("\t");
break;
}
}
Console.Write("\r\n");
}
}