单行印刷系列

时间:2018-11-25 17:30:46

标签: c# series

output

  

如何在一行中显示结果?
  我尝试将每个WriteLine替换为Write,但输出未更改。   我还尝试将i <= n替换为i

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
    static void Main(string[] args)
    {
        int n = 0, i;
        Console.WriteLine("Enter the limit");
        n = int.Parse(Console.ReadLine());

        for (i = 1; i <= n; i++)
        {
            if (i % 2 != 0)
            {
                Console.WriteLine("{0}", 1);
            }
            else
            {
                Console.WriteLine("{0}", 0);
            }
            Console.ReadKey();
        }
    }
}

}

0 个答案:

没有答案
相关问题