# include # include # include "polyomino_transform.h" int main ( ); /******************************************************************************/ int main ( ) /******************************************************************************/ /* Purpose: POLYOMINO_TRANSFORM_TEST tests POLYOMINO_TRANSFORM. Licensing: This code is distributed under the GNU LGPL license. Modified: 28 April 2018 Author: John Burkardt Local parameters: Local, int M, N, the number of rows and columns in the representation of the polyomino P. Local, int P[M*N], a matrix of 0's and 1's representing the polyomino. The matrix should be "tight", that is, there should be a 1 in row 1, and in column 1, and in row M, and in column N. */ { int i; int j; char label[80]; int m = 3; int mq; int n = 3; int nq; /* P is given by columns, not rows. */ int p[3*3] = { 0, 1, 0, 1, 1, 1, 1, 0, 0 }; int *q; int reflect; int rotate; timestamp ( ); printf ( "\n" ); printf ( "POLYOMINO_TRANSFORM_TEST:\n" ); printf ( " C version\n" ); printf ( " POLYOMINO_TRANSFORM can transform a polyomino.\n" ); printf ( " Generate all 8 combinations of rotation and reflection\n" ); printf ( " applied to a polyomino represented by a binary matrix.\n" ); polyomino_print ( m, n, p, " The given polyomino P:" ); for ( reflect = 0; reflect <= 1; reflect ++ ) { for ( rotate = 0; rotate <= 3; rotate++ ) { polyomino_transform ( m, n, p, rotate, reflect, &mq, &nq, &q ); sprintf ( label, " P after %d reflections and %d rotations:", reflect, rotate ); polyomino_print ( mq, nq, q, label ); free ( q ); } } /* Terminate. */ printf ( "\n" ); printf ( "POLYOMINO_TRANSFORM_TEST:\n" ); printf ( " Normal end of execution.\n" ); printf ( "\n" ); timestamp ( ); return 0; }