class Program
{
class Model
{
public string Code { get; set; }
}
static void Main(string[] args)
{
Console.WriteLine("请输入数字");
int num =Convert.ToInt32(Console.ReadLine()) ;
int m = 0;
if (num % 2 == 0)
m = num / 2;
else
m = num / 2 + 1;
List<Model> list = new List<Model>();
for (int n = 0; n < m; n++)
{
int j = 2 * n + 1;
int t = (num - j) / 2;
Model model = new Model { Code = $"{t}|{j}|{t}" };
list.Add(model);
}
for (int n = m - 2; n >= 0; n--)
{
int j = 2 * n + 1;
int t = (num - j) / 2;
Model model = new Model { Code = $"{t}|{j}|{t}" };
list.Add(model);
}
Write(list);
Console.ReadKey();
}
static void Write(List<Model> list)
{
list.ForEach(t =>
{
var arr = t.Code.Split('|');
string codetemp = "";
for (int i = 0; i < arr.Length; i++)
{
for (int j = 0; j < Convert.ToInt32(arr[i]); j++)
{
if (i == 1) codetemp += "*";
else codetemp += " ";
}
}
Console.WriteLine(codetemp);
});
}
}