在Visual Studio中,用“*”输出三角形。如图所示
代码如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
Console.Write("请输入一个数值:");
int a =Int32.Parse(Console.ReadLine());
for (int i = 1;i <= a;i++)
{
for (int n= 1; n <= a - i; n++)
{
Console.Write("");
}
for (int j= 1; j <= i; j++)
{
Console.Write("*");
}
Console.WriteLine();
}
Console.ReadLine();
}
}
}