这都是Windows控制台下的东西!
第一种是根据网上的方法 自己改的!
其后几种是同学不知道从哪抄的!
弄来 收藏下 算是一种思路吧!
第一种:
{
class Program
{
static void Main(string[] args)
{
int i, x;
for (i = 1; i <= 15; i++)
{
for (x = 1; x <= i; x++)
{
Console.Write(“*”);
}
Console.Write(“\n”);
}
}
}
}
图例一:
第二种:
{
class Program
{
static void Main(string[] args)
{
int i = 1;
for (int row = 1; row <= 10; row++)
{
for (int col = 1; col <= i; col++)
Console.Write(“*”);
Console.WriteLine();
i++;
}
}
}
}
图例二:
第三种:
{
class Program
{
static void Main(string[] args)
{
int y = 10;
for (int row = 1; row <= 10; row++)
{
for (int col = 1; col <= y; col++)
Console.Write(“*”);
Console.WriteLine();
y–;
}
}
}
}
图例三:
第四种(未完工):
{
class Program
{
static void Main(string[] args)
{
int i = 1;
for (int row = 1; row <= 10; row++)
{
for (int col = 1; col <= i; col++)
Console.Write(“*”);
Console.WriteLine();
i++;
}
int y = 10;
for (int row = 1; row <= 10; row++)
{
for (int col = 1; col <= y; col++)
Console.Write(“*”);
Console.WriteLine();
y–;
}
}
}
}
由代码可以看出来! 第一种利用的是排列 和 \n 的换行参数做出来的!
第二种用的row/col的行于列的参数做的!第三种和第二种只是区别于++/–!
第四种也就是第二种与第三种的集合罢了!