Ejemplo n.º 1
0
    public static void Main()
    {
        int        n, i;
        formPermut test = new formPermut();

        int[] arr1 = new int[5];

        Console.WriteLine("\n\n Recursion : Generate all possible permutations of an array :");
        Console.WriteLine("------------------------------------------------------------------");

        Console.Write(" Input the number of elements to store in the array [maximum 5 digits ] :");
        n = Convert.ToInt32(Console.ReadLine());
        Console.Write(" Input {0} number of elements in the array :\n", n);
        for (i = 0; i < n; i++)
        {
            Console.Write(" element - {0} : ", i);
            arr1[i] = Convert.ToInt32(Console.ReadLine());
        }

        Console.Write("\n The Permutations with a combination of {0} digits are : \n", n);
        test.prnPermut(arr1, 0, n - 1);
        Console.Write("\n\n");
    }
        // From https://stackoverflow.com/questions/7802822/all-possible-combinations-of-a-list-of-values
        private List <String> computePotentialKeys(List <String> pks)
        {
            formPermut test = new formPermut();

            return(test.prnPermut(pks.ToArray(), 0, pks.Count() - 1));
        }