在控制台应用程序下输出:
*
***
*****
*******
*****
***
*
我的代码如下:
using System;
namespace ConsoleApplication1
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
for(int i=-3;i<=3;i++)
{
int y = Math.Abs(i);
for(int j=1;j<=7-2*y;j++)
{
Console.WriteLine("*");
}
}
}
}
}
为什么得到的结果是25行,每行一个“*”呢,是不是Console.WriteLine()函数输出字符时后面默认每输出一次就换行?
*
***
*****
*******
*****
***
*
我的代码如下:
using System;
namespace ConsoleApplication1
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
for(int i=-3;i<=3;i++)
{
int y = Math.Abs(i);
for(int j=1;j<=7-2*y;j++)
{
Console.WriteLine("*");
}
}
}
}
}
为什么得到的结果是25行,每行一个“*”呢,是不是Console.WriteLine()函数输出字符时后面默认每输出一次就换行?