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

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

    class Program
    {
        static int temp = 0;
    
        public static int a()
        {
            temp = temp + 1;
    
            if (temp == 100)
            {
                Console.WriteLine(temp);
                return 0;
            }
    
            else
                Console.WriteLine(temp);
    
            Program.a();
            return 0;
        }
    
        public static void Main()
        {
            Program.a();
            Console.ReadLine();
        }
    }
    

提交回复
热议问题