MaxCombinations

CSharp · Console

/Program.cs

using System;

namespace MaxCombinations
{
    public class MaxCombinations
    {
        public static void Main()
        {
            int start = int.Parse(Console.ReadLine());
            int end = int.Parse(Console.ReadLine());
            int stop = int.Parse(Console.ReadLine());
            int counter = 0;

            for (int num1 = start; num1 <= end; num1++)  // we cycle the first number from "start" to "end"
            {
                if (counter >= stop)  // if after our last printed combination the counter reached the maximum value we break the loop and don't print anything
                {
                    break;
                }

                for (int num2 = start; num2 <= end; num2++) // we cycle the second number from "start to "end"
                {

                    if (counter >= stop)  // if after our last printed combination the counter reached the maximum value we break the loop and don't print anything
                    {
                        break;
                    }

                    Console.Write("<{0}-{1}>", num1, num2);
                    counter++; // after every printed combination we increase the counter
                }
            }
            Console.WriteLine();
        }
    }
}
;