Ejemplo n.º 1
0
    private static void subset_lex_successor_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    SUBSET_LEX_SUCCESSOR_TEST tests SUBSET_LEX_SUCCESSOR.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    03 December 2015
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        const int n = 5;

        Console.WriteLine("");
        Console.WriteLine("SUBSET_LEX_SUCCESSOR_TEST");
        Console.WriteLine("  SUBSET_LEX_SUCCESSOR lists,");
        Console.WriteLine("  subsets of a set,");
        Console.WriteLine("  using the lexicographic ordering,");

        int[] t = new int[n];

        int rank = -1;

        for (;;)
        {
            int rank_old = rank;

            Subset.subset_lex_successor(n, ref t, ref rank);

            if (rank <= rank_old)
            {
                break;
            }

            string cout = "  " + rank.ToString().PadLeft(4);
            int    i;
            for (i = 0; i < n; i++)
            {
                cout += "  " + t[i].ToString().PadLeft(4);
            }

            Console.WriteLine(cout);
        }
    }