/* * bingo [-f F] [-h F] n * * Col. G. L. Sicherman. December 1992. * You may use and modify this program as you like * so long as you leave this message in it and don't * try to make money from it. */ /* * This program prints a specified number of BINGO cards. * Its output is input for tbl, to be printed landscape- * style, two to a page: * * +-----------------+ * | | | * | | | * | | | * | | | * | | | * +-----------------+ * * The -f option specifies a font for the numbers. * The -h option specifies a font for the heading. */ /* * Feel free to change the randomization functions! */ #define RAND lrand48 #define SRAND srand48 #include #include char *progname; char *htypeface = "KB"; /* Cooper Black is nice if you have it */ char *typeface = "HB"; /* how about Computer Modern Math Italics? */ long time(), RAND(); void SRAND(); static void usage() { fprintf(stderr, "usage: %s [-f typeface] [-h typeface] cardcount\n", progname); exit(1); } main(argc,argv) int argc; char **argv; { char *s; int cardc; progname = argv[0]; while (--argc) { if ('-'!=**++argv) break; switch(*++*argv) { case 'h': if (!--argc) usage(); htypeface = *++argv; break; case 'f': if (!--argc) usage(); typeface = *++argv; break; default: usage(); } } if (argc != 1) usage(); for (s=argv[0]; *s; s++) if (!isdigit(*s)) { fprintf(stderr, "%s: cardcount must be a number\n", progname); exit(1); } cardc = atoi(argv[0]); if (cardc % 2) { fprintf(stderr, "%s: cardcount must be even\n", progname); exit(1); } SRAND(time(0)); printf(".\\\" tbl | qroff -L\n.pl 8.5i\n.ll 11i\n.ps 24\n.vs .65i\n"); while (cardc) { card("0.2"); cardc--; card("5.6"); cardc--; if (cardc) printf(".bp\n"); } exit(0); } card(po) char *po; { short used[5]; int r, i, val; printf(".sp |0.8i\n"); printf(".po %si\n", po); printf(".TS\nbox;\n"); printf("c1w(48p)f%s ", htypeface); for (i=1; i<5; i++) printf("c0w(1i)f%s ", htypeface); putchar('\n'); for (i=0; i<5; i++) printf("%s cf%s ", i? "|": " ", typeface); printf(".\n"); for (i=0; i<5; i++) { printf("\\s+8\\s+8\\s+8\\s+8\\&"); putchar("BINGO"[i]); printf("\\s-8\\s-8\\s-8\\s-8\\&"); putchar(i==4? '\n': '\t'); } printf("=\n"); for (i=0; i<5; i++) used[i] = 0; for (r=0; r<5; r++) { if (r) printf("_\n"); for (i=0; i<5; i++) { if (i) putchar('\t'); printf("\\s+8\\s+8\\s+8\\v'9p'"); if (r==2 && i==2) freespace(); else { do val = RAND()%15; while (used[i] & (1<