在C#的控制台应用程序中打印从1到1000的数字 [英] printing numbers from 1 to 1000 in console application in C#
本文介绍了在C#的控制台应用程序中打印从1到1000的数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
namespace print_number_1_to_1000
{
class Program
{
static void Main(string[] args)
{
for (int i = 1; i <= 1000; i=i+1)
{
Console.WriteLine(i);
}
Console.ReadLine();
}
}
}
但问题是它只能从702打印到1000
打印从1到1000的数字的代码是什么?
but the problem is it only prints from 702 to 1000
what would be the code to print number from 1 to 1000
推荐答案
尝试以下操作:
Try the following:
namespace print_number_1_to_1000
{
class Program
{
static void Main(string[] args)
{
Console.BufferHeight = 2000;
for (int i = 1; i <= 1000; i=i+1)
{
Console.WriteLine(i);
}
Console.ReadLine();
}
}
}
请参阅此处以获得说明:
http://msdn.microsoft.com/en-us/library/system.console. bufferheight.aspx [ ^ ]
See here for an explanation:
http://msdn.microsoft.com/en-us/library/system.console.bufferheight.aspx[^]
这将是您的代码...
This will be your code...
static void Main(string[] args)
{
for (int i = 1; i <= 1000; i++)
{
Console.Write(i+" ");
}
Console.ReadLine();
}
这篇关于在C#的控制台应用程序中打印从1到1000的数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文