namespace test
{
class Program
{
public static void Main(string[] args)
{
Console.WriteLine("please input the max: ");
int max = int.Parse(Console.ReadLine());
for (int i=0;i<max;i++)
{
for (int j = 0;j<max;j++)
{
if (i==0||i==max-1||j==0||j==max-1)
Console.Write("*");
else
Console.Write(" ");
}
Console.Write("\n");
}
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
}
}
效果:
输入5
*****
* *
* *
* *
*****