打印倒直角三角形
for (int i = 1; i <= 9; i++)
{
for (int j = 9; j >= i; j--)
{
Console.Write("*");
if (j == i)
{
Console.WriteLine();
}
}
}
Console.ReadKey();
打印正等腰三角形
for (int i = 1; i <= 9; i++)
{
for (int j = 9; j >=i; j--)
{
Console.Write(" ");
}
for (int j = 1; j <= i * 2 - 1; j++)
{
Console.Write("*");
}
Console.WriteLine();
}
Console.ReadKey();
|
|