# include # include # include using namespace std; # include "pentominoes.hpp" int main ( ); void pentomino_matrix_test ( ); void pentomino_plot_test ( ); //****************************************************************************80 int main ( ) //****************************************************************************80 // // 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: // // 22 April 2018 // // Author: // // John Burkardt // { timestamp ( ); cout << "\n"; cout << "PENTOMINOES_TEST\n"; cout << " C++ version\n"; cout << " Test the PENTOMINOES library.\n"; pentomino_matrix_test ( ); pentomino_plot_test ( ); // // Terminate. // cout << "\n"; cout << "PENTOMINOES_TEST\n"; cout << " Normal end of execution.\n"; cout << "\n"; timestamp ( ); return 0; } //****************************************************************************80 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 i; int j; int k; int *p; int p_m; int p_n; char pentominoes[12] = { 'F', 'I', 'L', 'N', 'P', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' }; cout << "\n"; cout << "PENTOMINO_MATRIX_TEST\n"; cout <<" PENTOMINO_MATRIX returns a 0/1 matrix representing a pentomino.\n"; for ( k = 0; k < 12; k++ ) { pentomino_matrix ( pentominoes[k], p_m, p_n, &p ); cout << "\n"; cout << " " << pentominoes[k] << " pentomino (" << p_m << "," << p_n << "):\n"; cout << "\n"; for ( i = 0; i < p_m; i++ ) { cout << " " ; for ( j = 0; j < p_n; j++ ) { cout << p[i*p_n+j]; } cout << "\n"; } delete [] p; } return; } //****************************************************************************80 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; string label; int *p; int p_m; int p_n; char pentominoes[12] = { 'F', 'I', 'L', 'N', 'P', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' }; cout << "\n"; cout << "PENTOMINO_PLOT_TEST\n"; cout << " PENTOMINO_PLOT plots a pentomino.\n"; for ( k = 0; k < 12; k++ ) { pentomino_matrix ( pentominoes[k], p_m, p_n, &p ); label = pentominoes[k]; pentomino_plot ( p_m, p_n, p, label ); } return; }