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
*****
* *
* *
* *
*****

本文将指导您如何使用C#编程语言通过控制台应用程序实现动态星形图案的生成,包括输入最大行数并根据指定条件打印星号。
3418

被折叠的 条评论
为什么被折叠?



