for (int i = 0; i < 10; i++)
{
for (int j = 0; j < (10 - i); j++)
{
System.Console.Write(" ");
}
for (int k = 0; k < (2 * i + 1);k++ )
{
System.Console.Write("*");
}
System.Console.WriteLine();
}
System.Console.WriteLine("以下为打印倒直角三角形:");
for (int i = 0; i < 10; i++)
{
for (int k = 0; k <= i ; k++)
{
System.Console.Write(" ");
}
for (int j = 0; j < 2 *(9 - i)+1; j++)
{
System.Console.Write("*");
}
System.Console.WriteLine();
}
System.Console.WriteLine("以下为打印菱形:");
for (int i = 0; i < 10; i++)//此for循环为打印上半部分
{
for (int j = 0; j < (10 - i); j++)//控制输出空格
{
System.Console.Write(" ");
}
for (int k = 0; k < (2 * i + 1); k++)//控制输出*
{
System.Console.Write("*");
}
System.Console.WriteLine();
}
for (int i = 0; i < 9; i++)//此for循环为打印下半部分
{
for (int k = 0; k <= i+1; k++)//控制输出空格
{
System.Console.Write(" ");
}
for (int j = 0; j < 2 * (8 - i) + 1; j++)//控制输出*
{
System.Console.Write("*");
}
System.Console.WriteLine();
}
System.Console.WriteLine("以下为打印空心菱形:");
for (int i = 0; i < 10; i++)//此for循环为打印上半部分
{
for (int j = 0; j < (10 - i); j++)//控制输出空格
{
System.Console.Write(" ");
}
System.Console.Write("*");
for (int k = 0; k < (2 * i - 1); k++)//控制输出空格
{
System.Console.Write(" ");
}
if (i != 0)
{
System.Console.Write("*");
}
System.Console.WriteLine();
}
for (int i = 0; i < 9; i++)//此for循环为打印下半部分
{
for (int k = 0; k <= i + 1; k++)//控制输出空格
{
System.Console.Write(" ");
}
System.Console.Write("*");
for (int j = 0; j < 2 * (7 - i) + 1; j++)//控制输出*
{
System.Console.Write(" ");
}
if (i != 8)
{
System.Console.Write("*");
}
System.Console.WriteLine();
}