while (true)
{
string s = "★";//s代表五角星
string t = "○";//t代表方格,如果需要只打印正三角形,可用空格键代替
int a = 1;//声明变量,初始值为1
Console.Write("请输入行数");
a = Convert.ToInt32(Console .ReadLine ());
for (int i = 1; i <= a; i++)
{
for (int x = 1; x <= a - i; x++)
{
Console.Write(t);//输出空格,
}
for (int x = 1; x <= 2 * i - 1; x++)
{
Console.Write(s);
}
Console.Write("\n");
打印结果
时间: 2024-10-26 07:29:03