正三角
for (int i = 0; i < 8; i++)
{
for (int j = 0; j < 15; j++)
{
int kong = 8 - i - 1;
int star = 2 * i + 1;
if (j < kong)
{
Console.Write(" ");
}
else if (j < kong + star)
{
Console.Write("*");
}
}
Console.WriteLine();
}
倒三角
for (int i = 0; i < 8; i++)
{
for (int j = 0; j < 8; j++)
{
if (j < i)
{
Console.Write(" ");
}
else
{
Console.Write("*");
}
}
for (int j = 7; j > i; j--)
{
Console.Write("*");
}
Console.WriteLine();
}