Advertisement
skipter

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

Jun 3rd, 2017
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.29 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace ConsoleApp9
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             int num1 = int.Parse(Console.ReadLine());
  13.             int num2 = int.Parse(Console.ReadLine());
  14.  
  15.             Boolean check = false;
  16.            
  17.             for (int a = num1; a <= num2; a++)
  18.             {
  19.                 for (int b = num1; b <= num2; b++)
  20.                 {
  21.                     for (int c = num1; c <= num2; c++)
  22.                     {
  23.                         for (int d = num1; d <= num2; d++)
  24.                         {
  25.                             for (int e = num1; e <= num2; e++)
  26.                             {
  27.                                 if (num1 <= a && a < b && b < c && c < d && d < e && e <= num2)
  28.                                 {
  29.                                     Console.WriteLine($"{a} {b} {c} {d} {e}");
  30.                                     check = true;
  31.                                 }
  32.  
  33.                             }
  34.                         }
  35.                     }
  36.                 }
  37.             }
  38.             if (check == false)
  39.             {
  40.                 Console.WriteLine("No");
  41.             }
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement