Printing numbers from 1 to 1000 in console applica

2019-07-25 14:40发布

The problem is it only prints from 702 to 1000. What should be the code to print number from 1 to 1000.

static void Main(string[] args)
        {
            //    Console.Write("\tOutput : " + arr[0] + arr[1] + arr[2] + arr[3] + "\n");
            //int[] arr = new int[4] { 0, 0, 0, 0 };


            for (int i=0; i<=1000; i++)
            {
                Console.WriteLine(i);
            }
            Console.ReadKey();
        }

1条回答
不美不萌又怎样
2楼-- · 2019-07-25 15:18

You only see the last 300 or so lines because your console window has a limited line buffer.

Your code is fine (besides that it also prints 0) as you will see when you increase the line buffer size or redirect stdout to a file like so:

myprogram.exe > output.log

查看更多
登录 后发表回答