用C#语言!在控制台打印如图所示,要求输入一个参数以控制打印行数
5个回答
展开全部
修改了一下。
int n = int.Parse(Console.ReadLine());
int temp = 1, j;
for (int i = 1; i <= n; i++)
{
for (j = 1; j <= i; j++)
{
if (j == 1)
Console.Write(temp);
else
Console.Write(temp+j-1);
}
temp = temp + j - 1;
Console.WriteLine();
}
int n = int.Parse(Console.ReadLine());
int temp = 1, j;
for (int i = 1; i <= n; i++)
{
for (j = 1; j <= i; j++)
{
if (j == 1)
Console.Write(temp);
else
Console.Write(temp+j-1);
}
temp = temp + j - 1;
Console.WriteLine();
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
楼上朋友的答案好像有点问题哦……
int level = int.Parse(Console.ReadLine());
int counter = 1;
for (int row = 1; row <= level; row++)
{
for (int column = 1; column <= row; column++)
{
Console.Write("{0}\t", counter++);
}
Console.WriteLine();
}
___________________
补充:
using System;
public class MyClass
{
public static void Main()
{
Console.Write("请输入层数:");
int level = int.Parse(Console.ReadLine());
int counter = 1;
for (int row = 1; row <= level; row++)
{
for (int column = 1; column <= row; column++)
{
Console.Write("{0}\t", counter++);
}
Console.WriteLine();
}
Console.WriteLine("按任意键退出……");
Console.ReadKey();
}
}
int level = int.Parse(Console.ReadLine());
int counter = 1;
for (int row = 1; row <= level; row++)
{
for (int column = 1; column <= row; column++)
{
Console.Write("{0}\t", counter++);
}
Console.WriteLine();
}
___________________
补充:
using System;
public class MyClass
{
public static void Main()
{
Console.Write("请输入层数:");
int level = int.Parse(Console.ReadLine());
int counter = 1;
for (int row = 1; row <= level; row++)
{
for (int column = 1; column <= row; column++)
{
Console.Write("{0}\t", counter++);
}
Console.WriteLine();
}
Console.WriteLine("按任意键退出……");
Console.ReadKey();
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
楼上朋友的答案好像有点问题哦……
int
level
=
int.Parse(Console.ReadLine());
int
counter
=
1;
for
(int
row
=
1;
row
<=
level;
row++)
{
for
(int
column
=
1;
column
<=
row;
column++)
{
Console.Write("{0}\t",
counter++);
}
Console.WriteLine();
}
___________________
补充:
using
System;
public
class
MyClass
{
public
static
void
Main()
{
Console.Write("请输入层数:");
int
level
=
int.Parse(Console.ReadLine());
int
counter
=
1;
for
(int
row
=
1;
row
<=
level;
row++)
{
for
(int
column
=
1;
column
<=
row;
column++)
{
Console.Write("{0}\t",
counter++);
}
Console.WriteLine();
}
Console.WriteLine("按任意键退出……");
Console.ReadKey();
}
}
int
level
=
int.Parse(Console.ReadLine());
int
counter
=
1;
for
(int
row
=
1;
row
<=
level;
row++)
{
for
(int
column
=
1;
column
<=
row;
column++)
{
Console.Write("{0}\t",
counter++);
}
Console.WriteLine();
}
___________________
补充:
using
System;
public
class
MyClass
{
public
static
void
Main()
{
Console.Write("请输入层数:");
int
level
=
int.Parse(Console.ReadLine());
int
counter
=
1;
for
(int
row
=
1;
row
<=
level;
row++)
{
for
(int
column
=
1;
column
<=
row;
column++)
{
Console.Write("{0}\t",
counter++);
}
Console.WriteLine();
}
Console.WriteLine("按任意键退出……");
Console.ReadKey();
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
console.setwindowsize这个是设置高和宽的。
至于你说的最大行数,我觉得应该没有,因为字体font是可变化的,大小可变,怎么能确定显示的最大行数呢?
console.bufferheight等是设置缓冲区高度的。
至于你说的最大行数,我觉得应该没有,因为字体font是可变化的,大小可变,怎么能确定显示的最大行数呢?
console.bufferheight等是设置缓冲区高度的。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
修改了一下。
int
n
=
int.Parse(Console.ReadLine());
int
temp
=
1,
j;
for
(int
i
=
1;
i
<=
n;
i++)
{
for
(j
=
1;
j
<=
i;
j++)
{
if
(j
==
1)
Console.Write(temp);
else
Console.Write(temp+j-1);
}
temp
=
temp
+
j
-
1;
Console.WriteLine();
}
int
n
=
int.Parse(Console.ReadLine());
int
temp
=
1,
j;
for
(int
i
=
1;
i
<=
n;
i++)
{
for
(j
=
1;
j
<=
i;
j++)
{
if
(j
==
1)
Console.Write(temp);
else
Console.Write(temp+j-1);
}
temp
=
temp
+
j
-
1;
Console.WriteLine();
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询