How to print 1 to 100 without any looping using C#

后端 未结 28 1447
天命终不由人
天命终不由人 2020-12-22 19:30

I am trying to print numbers from 1 to 100 without using loops, using C#. Any clues?

28条回答
  •  轮回少年
    2020-12-22 20:08

    The cool and funny way:

    static void F(int[] array, int n)
    {
        Console.WriteLine(array[n] = n);
        F(array, n + 1);
    }
    static void Main(string[] args)
    {
        try { F(new int[101], 1); }
        catch (Exception e) { }
    }
    

提交回复
热议问题