using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _7._19day03
{
internal class Program
{
static void Main(string[] args)
{
Print(7);
Console.WriteLine("------------------");
Print2(7);
Console.WriteLine("------------------");
Print5(7);
Console.WriteLine("------------------");
Print4(7);
Console.WriteLine("------------------");
Print3(7);
Console.ReadKey();
}
public static void Print(int a)
{
for (int i = 1; i <= a; i++)
{
for (int j = a - i; j > 0; j--)
{
Console.Write(" ");
}
for (int k = 2 * i - 1; k > 0; k--)
{
Console.Write("*");
}
Console.WriteLine();
}
}
public static void Print2(int a)
{
for (int i = 0; i < a; i++)
{
for (int j = 0; j < a - i; j++)
{
Console.Write("*");
}
Console.WriteLine();
}
}
public static void Print3(int a)
{
for (int i = 0; i < a; i++)
{
for (int j = 0; j < i + 1; j++)
{
Console.Write("*");
}
Console.WriteLine();
}
}
public static void Print4(int a)
{
for (int i = 0; i < a; i++)
{
for (int j = a - 1 - i; j > 0; j--)
{
Console.Write(" ");
}
for (int j = 1; j <= i + 1; j++)
{
Console.Write("*");
}
Console.WriteLine();
}
}
public static void Print5(int a)
{
for (int i = 0; i < a; i++)
{
for (int j = 1; j <= i; j++)
{
Console.Write(" ");
}
for (int j = a - i; j > 0; j--)
{
Console.Write("*");
}
Console.WriteLine();
}
}
}
}
用C#打印等腰三角形,打印四个方向的直角三角形
2024-07-20 12:34:06 23 阅读