Advertisement
Guest User

Untitled

a guest
Mar 6th, 2017
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.02 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Increasing4Numbers
  4. {
  5.     class Increasing4Numbers
  6.     {
  7.         static int A, B;
  8.         const int N = 4;
  9.         static int[] arr = new int[N];
  10.  
  11.         static void Main(string[] args)
  12.         {
  13.             int a = int.Parse(Console.ReadLine()),
  14.                 b = int.Parse(Console.ReadLine());
  15.  
  16.             if (b - a < N - 1)
  17.             {
  18.                 Console.WriteLine("No");
  19.                 return;
  20.             }
  21.  
  22.             A = a;
  23.             B = b;
  24.  
  25.             GenerateVariations ( 0, A ) ;
  26.         }
  27.  
  28.         static void GenerateVariations ( int index, int value )
  29.         {
  30.             if (index == N)
  31.                 PrintArray();
  32.             else
  33.                 for ( int i = value; i <= B; i++ )
  34.                 {
  35.                     arr[index] = i;
  36.                     GenerateVariations ( index + 1, i + 1 );
  37.                 }
  38.         }
  39.  
  40.         static void PrintArray()
  41.         {
  42.             Console.WriteLine(string.Join(" ", arr));
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement