static void Main(string[] args)
{
jinzita da = new jinzita();
da.fa();
Console.ReadLine();
}
}
class jinzita
{
public void fa()
{
Console.WriteLine("请输入一个一到九的整数");
int n = 0;
n = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("您输入的数是:" + n);
//遍历行
for (int hang = 1; hang <= n; hang++)
{
//留空格
for (int count = 1; count <= n - hang; count++)
{
Console.Write(" ");
}
//写左边数字
for (int i = 1; i <= hang; i++)
{
Console.Write(i + " ");
}
if (hang == 1)
{
Console.WriteLine("");
}
else
{
//写右边数字
for (int j = hang - 1; j >= 1; j--)
{
Console.Write(j + " ");
if (j == 1)
{
Console.WriteLine("");
}
}
}
}
}
{
jinzita da = new jinzita();
da.fa();
Console.ReadLine();
}
}
class jinzita
{
public void fa()
{
Console.WriteLine("请输入一个一到九的整数");
int n = 0;
n = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("您输入的数是:" + n);
//遍历行
for (int hang = 1; hang <= n; hang++)
{
//留空格
for (int count = 1; count <= n - hang; count++)
{
Console.Write(" ");
}
//写左边数字
for (int i = 1; i <= hang; i++)
{
Console.Write(i + " ");
}
if (hang == 1)
{
Console.WriteLine("");
}
else
{
//写右边数字
for (int j = hang - 1; j >= 1; j--)
{
Console.Write(j + " ");
if (j == 1)
{
Console.WriteLine("");
}
}
}
}
}