使用for循环打印直角三角形
for (int i = 1; i <= 9; i++)
{
Console.WriteLine();
for (int j = 1; j <= i; j++)
{
Console.Write( "*" );
Console.Write(" ");
}
}
Console.Read();
使用for循环打印等腰三角形
for (int i = 1; i <= 9; i++)
{
Console.WriteLine();
for (int j = 1; j <= 9-i; j++)
{
Console.Write(" ");
}
for (int j = 1; j < 2 * i- 1; j++)
{
if (i==9 || j==1 || j==2*i-1)
{
Console.Write(" ");
}
else
{
Console.Write("*");
}
}
}
Console.Read();
打印九九乘法表
for (int i = 1; i <= 9; i++)
{
Console.WriteLine();
for (int j = 1; j <= i; j++)
{
Console.Write(j + "*" + i + "=" + j * i);
Console.Write(" ");
}
}
Console.Read();