using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 打印菱形
{
class Program
{
static void Main(string[] args)
{
PrintMath(21);
Console.ReadKey();
}
static void PrintMath(int a)
{
int x = 0;
int count = 0;
int s = 2;
int c = 2;
for (int i = 1; i <= a; i++)
{
if (i <= (a / 2 + 1))
{
x = ((a / 2) + 1) - (i - 1);
}
else
{
x = s;
}
for (int j = 1; j <= a; j++)
{
if (i <= (a / 2 + 1))
{
if (j == x && count < i)
{
Console.Write("*");
x += 2;
count++;
}
else
{
Console.Write(" ");
}
}
else if (i > (a / 2 + 1))
{
if (j == x && count < i - c)
{
Console.Write("*");
x += 2;
count++;
}
else
{
Console.Write(" ");
}
}
}
if (i > (a / 2 + 1))
{
c += 2;
s++;
}
count = 0;
Console.Write("\n");
}
}
}
}