skipter icon

C# Fundamentals - 5 Different Numbers / 5 for loops + if

skipter | PRO | 06/03/17 07:20:33 AM UTC | 0 ⭐ | 302 👁️ | Never ⏰ | []
C# |

1.29 KB

|

None

|

0 👍

/

0 👎

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp9
{
    class Program
    {
        static void Main(string[] args)
        {
            int num1 = int.Parse(Console.ReadLine());
            int num2 = int.Parse(Console.ReadLine());
 
            Boolean check = false;
            
            for (int a = num1; a <= num2; a++)
            {
                for (int b = num1; b <= num2; b++)
                {
                    for (int c = num1; c <= num2; c++)
                    {
                        for (int d = num1; d <= num2; d++)
                        {
                            for (int e = num1; e <= num2; e++)
                            {
                                if (num1 <= a && a < b && b < c && c < d && d < e && e <= num2)
                                {
                                    Console.WriteLine($"{a} {b} {c} {d} {e}");
                                    check = true;
                                }
 
                            }
                        }
                    }
                }
            }
            if (check == false)
            {
                Console.WriteLine("No");
            }
        }
    }
}

Comments