SHARE
TWEET

02.01.20.Variations

stanevplamen Jul 2nd, 2013 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.  
  3. public static class GlobalMembersPermutationsWithRepetition
  4. {
  5.     public static uint[] numbersArray = new uint[100];
  6.     public static uint iteration;
  7.     public static void Print()
  8.     {
  9.         uint i;
  10.         for (i = 0; i < iteration; i++)
  11.         {
  12.             Console.Write("{0:D} ", numbersArray[i] + 1);
  13.         }
  14.         Console.Write("\n");
  15.     }
  16.     public static int length;
  17.     public static void Permute(uint start)
  18.     {
  19.         uint k;
  20.         if (start >= iteration)
  21.         {
  22.             GlobalMembersPermutationsWithRepetition.Print();
  23.             return;
  24.         }
  25.         for (k = 0; k < length; k++)
  26.         {
  27.             numbersArray[start] = k;
  28.             /* if */
  29.             GlobalMembersPermutationsWithRepetition.Permute(start + 1);
  30.         }
  31.     }
  32.     static void Main()
  33.     {
  34.         Console.Write("Please enter N = ");
  35.         length = int.Parse(Console.ReadLine());
  36.         Console.Write("Please enter K = ");
  37.         iteration = uint.Parse(Console.ReadLine());
  38.  
  39.         GlobalMembersPermutationsWithRepetition.Permute(0);
  40.     }
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top