1个回答
展开全部
Console.WriteLine("请输入等边三角形高度:");
string line = Console.ReadLine();
int height = 3;
if (false == int.TryParse(line, out height))
{
Console.WriteLine("输入高度不是合法整数,默认高度3执行");
}
for (int h = 0; h < height; h++)
{
for (int idx = 0; idx <= 2 * height - 1; idx++)
{
if (idx > height - h - 1 && idx <=height - h - 1 + 2 * h + 1)
{
Console.Write("*");
}
else
{
Console.Write(" ");
}
}
Console.WriteLine();
}
Console.Write("按任意键退出程序");
Console.ReadKey();
string line = Console.ReadLine();
int height = 3;
if (false == int.TryParse(line, out height))
{
Console.WriteLine("输入高度不是合法整数,默认高度3执行");
}
for (int h = 0; h < height; h++)
{
for (int idx = 0; idx <= 2 * height - 1; idx++)
{
if (idx > height - h - 1 && idx <=height - h - 1 + 2 * h + 1)
{
Console.Write("*");
}
else
{
Console.Write(" ");
}
}
Console.WriteLine();
}
Console.Write("按任意键退出程序");
Console.ReadKey();
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询