コード例 #1
0
    private static void pentomino_matrix_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    PENTOMINO_MATRIX_TEST tests PENTOMINO_MATRIX.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    22 April 2018
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int k;

        int[] p   = null;
        int   p_m = 0;
        int   p_n = 0;

        string[] pentominoes =
        { "F", "I", "L", "N", "P", "T", "U", "V", "W", "X", "Y", "Z" };

        Console.WriteLine("");
        Console.WriteLine("PENTOMINO_MATRIX_TEST");
        Console.WriteLine("  PENTOMINO_MATRIX returns a 0/1 matrix representing a pentomino.");

        for (k = 0; k < 12; k++)
        {
            Pentomino.pentomino_matrix(pentominoes[k], ref p_m, ref p_n, ref p);
            Console.WriteLine("");
            Console.WriteLine("  " + pentominoes[k] + " pentomino (" + p_m + "," + p_n + "):");
            Console.WriteLine("");
            int i;
            for (i = 0; i < p_m; i++)
            {
                string cout = "    ";
                int    j;
                for (j = 0; j < p_n; j++)
                {
                    cout += p[i * p_n + j];
                }

                Console.WriteLine(cout);
            }
        }
    }
コード例 #2
0
    private static void pentomino_plot_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    PENTOMINO_PLOT_TEST tests PENTOMINO_PLOT.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    22 April 2018
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int k;

        int[] p   = null;
        int   p_m = 0;
        int   p_n = 0;

        string[] pentominoes =
        { "F", "I", "L", "N", "P", "T", "U", "V", "W", "X", "Y", "Z" };

        Console.WriteLine("");
        Console.WriteLine("PENTOMINO_PLOT_TEST");
        Console.WriteLine("  PENTOMINO_PLOT plots a pentomino.");

        for (k = 0; k < 12; k++)
        {
            Pentomino.pentomino_matrix(pentominoes[k], ref p_m, ref p_n, ref p);
            string label = pentominoes[k];
            Pentomino.pentomino_plot(p_m, p_n, p, label);
        }
    }