static void LingXing(int n)
writeline函数{
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n - i; j++)//空格数=上半部总行数-行号
{
Console.Write(" ");
Console.Write("  ");
}
for (int k = 1; k <= 2 * i - 1; k++)//星号数=2倍的行号-1
{
Console.Write("*");
Console.Write("  ");
}
Console.WriteLine();
}
for (int i = 1; i < n; i++)
{
for (int j = 1; j <= i; j++)//下半部空格=行号
{
Console.Write(" ");
Console.Write("  ");
}
for (int k = 1; k <= (2 * n - 1) - 2 * i; k++)//星号数=2倍的上半部行-数-2倍的行号;
{
Console.Write("*");
Console.Write("  ");
}
Console.WriteLine();
}
}
static void Main(string[] args)
{
Console.WriteLine("输入想要的行数");
int m = int.Parse(Console.ReadLine());
int n = m / 2+1;
//Console.WriteLine(LingXing(n));
LingXing(n);
}

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。