using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace sanjiao01
{
class Program
{
static void Main(string[] args)
{
int n;
string inStr;
Console.WriteLine("请输入一个 1-20 之间的整数:");
inStr = Console.ReadLine();
if (int.TryParse(inStr, out n) == true)
{
three(n);
}
else Console.WriteLine(inStr + "不能转换成整型");
Console.ReadKey();
}
static void three(int n)
{
for (int i = 0; i < n; i++)
{
for (int j = 0; j <= (n - (i + 1)); j++)
{
Console.Write(" ");
}
for (int j = 0; j < 2 * i + 1; j++)
{
Console.Write("*");
}
Console.WriteLine();
}
}
}
}
C#三角形
最新推荐文章于 2022-05-09 10:47:42 发布