# include # include # include # include # include "pentominoes.h" int main ( ); void pentomino_matrix_test ( ); void pentomino_plot_test ( ); /******************************************************************************/ int main ( ) /******************************************************************************/ /* Purpose: MAIN is the main program for PENTOMINOES_TEST. Discussion: PENTOMINOES_TEST tests the PENTOMINOES library. Licensing: This code is distributed under the GNU LGPL license. Modified: 21 April 2018 Author: John Burkardt */ { timestamp ( ); printf ( "\n" ); printf ( "PENTOMINOES_TEST\n" ); printf ( " C version\n" ); printf ( " Test the PENTOMINOES library.\n" ); pentomino_matrix_test ( ); pentomino_plot_test ( ); /* Terminate. */ printf ( "\n" ); printf ( "PENTOMINOES_TEST\n" ); printf ( " Normal end of execution.\n" ); printf ( "\n" ); timestamp ( ); return 0; } /******************************************************************************/ void pentomino_matrix_test ( ) /******************************************************************************/ /* Purpose: PENTOMINO_MATRIX_TEST tests PENTOMINO_MATRIX. Licensing: This code is distributed under the GNU LGPL license. Modified: 21 April 2018 Author: John Burkardt */ { int i; int j; int k; char name; int *p; int p_m; int p_n; char pentominoes[12] = { 'F', 'I', 'L', 'N', 'P', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' }; printf ( "\n" ); printf ( "PENTOMINO_MATRIX_TEST\n" ); printf ( " PENTOMINO_MATRIX returns a 0/1 matrix representing a pentomino.\n" ); for ( k = 0; k < 12; k++ ) { name = pentominoes[k]; pentomino_matrix ( name, &p_m, &p_n, &p ); printf ( "\n" ); printf ( " %c pentomino (%d,%d):\n", name, p_m, p_n ); printf ( "\n" ); for ( i = 0; i < p_m; i++ ) { printf ( " " ); for ( j = 0; j < p_n; j++ ) { printf ( "%d", p[i*p_n+j] ); } printf ( "\n" ); } free ( p ); } return; } /******************************************************************************/ void pentomino_plot_test ( ) /******************************************************************************/ /* Purpose: PENTOMINO_PLOT_TEST tests PENTOMINO_PLOT. Licensing: This code is distributed under the GNU LGPL license. Modified: 21 April 2018 Author: John Burkardt */ { int k; char label[2]; char name; int *p; int p_m; int p_n; char pentominoes[12] = { 'F', 'I', 'L', 'N', 'P', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' }; printf ( "\n" ); printf ( "PENTOMINO_PLOT_TEST\n" ); printf ( " PENTOMINO_PLOT plots a pentomino.\n" ); for ( k = 0; k < 12; k++ ) { name = pentominoes[k]; sprintf ( label, "%c", name ); pentomino_matrix ( name, &p_m, &p_n, &p ); pentomino_plot ( p_m, p_n, p, label ); } return; }