C#如何输出

来源:百度知道 编辑:UC知道 时间:2024/05/07 18:37:31
*
**
***
****

for(int i=1;i<=4;i++)
{
for(int j=0;j<i;j++)
{
Console.Write("*");
}
Console.WriteLine();
}

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
for (int i = 0; i < 4; i++)
{
for (int m = 0; m < i+1; m++)
{
Console.Write("*");
}
Console.WriteLine();
}
Console.ReadLine();
}
}
}

已经把程序精简到只有一个FOR循环了
貌似楼主在另外一个区域也发了一个一模一样的问题,哈哈.路过..正好看到

static void Main(string[] args)
{
for (int a = 1; a <= 4; a++) {
Console.WriteLine(new string('*',a));
}
}

这个基本完整的程序,有选择是否实心,而且有差错功能···你自己看吧