Пример #1
0
    public static void ksub_random4_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    KSUB_RANDOM4_TEST tests KSUB_RANDOM4.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    07 March 2007
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        const int K = 3;
        const int N = 5;

        int[] a = new int[N];
        int   i;

        Console.WriteLine("");
        Console.WriteLine("KSUB_RANDOM4_TEST");
        Console.WriteLine("  KSUB_RANDOM4 generates a random K subset of an N set.");
        Console.WriteLine("  Set size is N =    " + N + "");
        Console.WriteLine("  Subset size is K = " + K + "");
        Console.WriteLine("");

        int seed = 123456789;

        for (i = 1; i <= 10; i++)
        {
            string cout = "";
            Ksub.ksub_random4(N, K, ref seed, ref a);
            int j;
            for (j = 0; j < K; j++)
            {
                cout += "  " + a[j].ToString().PadLeft(3);
            }

            Console.WriteLine(cout);
        }
    }