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

后端 未结 28 1536
天命终不由人
天命终不由人 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 19:59

    static void Main(string[] args)
            {
    
                print(0);
            }
    
            public static void print(int i)
            {
                if (i >= 0 && i<=10)
                {
    
                    i = i + 1;
                    Console.WriteLine(i + " ");
                    print(i);
                }
    }
    

提交回复
热议问题