home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / games / volume18 / bingocrd / part01 < prev    next >
Encoding:
Text File  |  1993-07-11  |  5.9 KB  |  237 lines

  1. Path: uunet!news.tek.com!saab!billr
  2. From: billr@saab.CNA.TEK.COM (Bill Randle)
  3. Newsgroups: comp.sources.games
  4. Subject: v18i010:  bingocard - print bingo cards, Part01/01
  5. Date: 10 Jul 1993 20:55:08 GMT
  6. Organization: Tektronix, Inc, Redmond, OR, USA
  7. Lines: 224
  8. Approved: billr@saab.CNA.TEK.COM
  9. Message-ID: <21nabc$orp@ying.cna.tek.com>
  10. NNTP-Posting-Host: saab.cna.tek.com
  11. Xref: uunet comp.sources.games:1810
  12.  
  13. Submitted-by: gls@windmill.att.COM
  14. Posting-number: Volume 18, Issue 10
  15. Archive-name: bingocard/part01
  16. Environment: tbl, *roff
  17.  
  18.  
  19. #! /bin/sh
  20. # This is a shell archive.  Remove anything before this line, then unpack
  21. # it by saving it into a file and typing "sh file".  To overwrite existing
  22. # files, type "sh file -c".  You can also feed this as standard input via
  23. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  24. # will see the following message at the end:
  25. #        "End of archive 1 (of 1)."
  26. # Contents:  README MANIFEST bingo.c
  27. # Wrapped by billr@saab on Sat Jul 10 13:52:50 1993
  28. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  29. if test -f 'README' -a "${1}" != "-c" ; then 
  30.   echo shar: Will not clobber existing file \"'README'\"
  31. else
  32. echo shar: Extracting \"'README'\" \(384 characters\)
  33. sed "s/^X//" >'README' <<'END_OF_FILE'
  34. XThis program prints a specified number of BINGO cards.
  35. XIts output is input for tbl, to be printed landscape-
  36. Xstyle, two to a page:
  37. X
  38. X        +-----------------+
  39. X        |        |        |
  40. X        |        |        |
  41. X        |        |        |
  42. X        |        |        |
  43. X        |        |        |
  44. X        +-----------------+
  45. X
  46. XThe -f option specifies a font for the numbers.
  47. XThe -h option specifies a font for the heading.
  48. X
  49. END_OF_FILE
  50. if test 384 -ne `wc -c <'README'`; then
  51.     echo shar: \"'README'\" unpacked with wrong size!
  52. fi
  53. # end of 'README'
  54. fi
  55. if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  56.   echo shar: Will not clobber existing file \"'MANIFEST'\"
  57. else
  58. echo shar: Extracting \"'MANIFEST'\" \(207 characters\)
  59. sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
  60. X   File Name        Archive #    Description
  61. X-----------------------------------------------------------
  62. X MANIFEST                   1    This shipping list
  63. X README                     1    
  64. X bingo.c                    1    
  65. END_OF_FILE
  66. if test 207 -ne `wc -c <'MANIFEST'`; then
  67.     echo shar: \"'MANIFEST'\" unpacked with wrong size!
  68. fi
  69. # end of 'MANIFEST'
  70. fi
  71. if test -f 'bingo.c' -a "${1}" != "-c" ; then 
  72.   echo shar: Will not clobber existing file \"'bingo.c'\"
  73. else
  74. echo shar: Extracting \"'bingo.c'\" \(2816 characters\)
  75. sed "s/^X//" >'bingo.c' <<'END_OF_FILE'
  76. X/*
  77. X *    bingo [-f F] [-h F] n
  78. X *
  79. X *    Col. G. L. Sicherman.  December 1992.
  80. X *    You may use and modify this program as you like
  81. X *    so long as you leave this message in it and don't
  82. X *    try to make money from it.
  83. X */
  84. X
  85. X/*
  86. X *    This program prints a specified number of BINGO cards.
  87. X *    Its output is input for tbl, to be printed landscape-
  88. X *    style, two to a page:
  89. X *
  90. X *            +-----------------+
  91. X *            |        |        |
  92. X *            |        |        |
  93. X *            |        |        |
  94. X *            |        |        |
  95. X *            |        |        |
  96. X *            +-----------------+
  97. X *
  98. X *    The -f option specifies a font for the numbers.
  99. X *    The -h option specifies a font for the heading.
  100. X */
  101. X
  102. X/*
  103. X *    Feel free to change the randomization functions!
  104. X */
  105. X
  106. X#define RAND lrand48
  107. X#define SRAND srand48
  108. X
  109. X#include <ctype.h>
  110. X#include <stdio.h>
  111. X
  112. Xchar *progname;
  113. Xchar *htypeface = "KB";    /* Cooper Black is nice if you have it */
  114. Xchar *typeface = "HB";    /* how about Computer Modern Math Italics? */
  115. X
  116. Xlong time(), RAND();
  117. Xvoid SRAND();
  118. X
  119. Xstatic void
  120. Xusage()
  121. X{
  122. X    fprintf(stderr,
  123. X    "usage: %s [-f typeface] [-h typeface] cardcount\n", progname);
  124. X    exit(1);
  125. X}
  126. X
  127. Xmain(argc,argv)
  128. Xint argc;
  129. Xchar **argv;
  130. X{
  131. X    char *s;
  132. X    int cardc;
  133. X
  134. X    progname = argv[0];
  135. X    while (--argc) {
  136. X        if ('-'!=**++argv) break;
  137. X        switch(*++*argv) {
  138. X        case 'h':
  139. X            if (!--argc) usage();
  140. X            htypeface = *++argv;
  141. X            break;
  142. X        case 'f':
  143. X            if (!--argc) usage();
  144. X            typeface = *++argv;
  145. X            break;
  146. X        default: usage();
  147. X        }
  148. X    }
  149. X    if (argc != 1) usage();
  150. X    for (s=argv[0]; *s; s++) if (!isdigit(*s)) {
  151. X        fprintf(stderr, "%s: cardcount must be a number\n", progname);
  152. X        exit(1);
  153. X    }
  154. X    cardc = atoi(argv[0]);
  155. X    if (cardc % 2) {
  156. X        fprintf(stderr, "%s: cardcount must be even\n", progname);
  157. X        exit(1);
  158. X    }
  159. X    SRAND(time(0));
  160. X    printf(".\\\" tbl | qroff -L\n.pl 8.5i\n.ll 11i\n.ps 24\n.vs .65i\n");
  161. X    while (cardc) {
  162. X        card("0.0"); cardc--;
  163. X        card("5.4"); cardc--;
  164. X        if (cardc) printf(".bp\n");
  165. X    }
  166. X    exit(0);
  167. X}
  168. X
  169. Xcard(po)
  170. Xchar *po;
  171. X{
  172. X    short used[5];
  173. X    int r, i, val;
  174. X
  175. X    printf(".sp |0.8i\n");
  176. X    printf(".po %si\n", po);
  177. X    printf(".TS\nbox;\n");
  178. X    printf("c1w(48p)f%s ", htypeface);
  179. X    for (i=1; i<5; i++) printf("c0w(1i)f%s ", htypeface);
  180. X    putchar('\n');
  181. X    for (i=0; i<5; i++) printf("%s cf%s ", i? "|": " ", typeface);
  182. X    printf(".\n");
  183. X    for (i=0; i<5; i++) {
  184. X        printf("\\s+8\\s+8\\s+8\\s+8\\&");
  185. X        putchar("BINGO"[i]);
  186. X        printf("\\s-8\\s-8\\s-8\\s-8\\&");
  187. X        putchar(i==4? '\n': '\t');
  188. X    }
  189. X    printf("=\n");
  190. X    for (i=0; i<5; i++) used[i] = 0;
  191. X    for (r=0; r<5; r++) {
  192. X        if (r) printf("_\n");
  193. X        for (i=0; i<5; i++) {
  194. X            if (i) putchar('\t');
  195. X            printf("\\s+8\\s+8\\s+8\\v'9p'");
  196. X            if (r==2 && i==2) freespace();
  197. X            else {
  198. X                do val = RAND()%15;
  199. X                while (used[i] & (1<<val));
  200. X                used[i] |= 1<<val;
  201. X                printf("%d", 1 + i*15 + val); 
  202. X            }
  203. X            printf("\\v'-9p'\\s-8\\s-8\\s-8\\&");
  204. X        }
  205. X        putchar('\n');
  206. X    }
  207. X    printf(".TE\n");
  208. X}
  209. X
  210. Xfreespace()
  211. X{
  212. X    printf("\\f(ZD_\\fP");
  213. X}
  214. END_OF_FILE
  215. if test 2816 -ne `wc -c <'bingo.c'`; then
  216.     echo shar: \"'bingo.c'\" unpacked with wrong size!
  217. fi
  218. # end of 'bingo.c'
  219. fi
  220. echo shar: End of archive 1 \(of 1\).
  221. cp /dev/null ark1isdone
  222. MISSING=""
  223. for I in 1 ; do
  224.     if test ! -f ark${I}isdone ; then
  225.     MISSING="${MISSING} ${I}"
  226.     fi
  227. done
  228. if test "${MISSING}" = "" ; then
  229.     echo You have the archive.
  230.     rm -f ark[1-9]isdone
  231. else
  232.     echo You still need to unpack the following archives:
  233.     echo "        " ${MISSING}
  234. fi
  235. ##  End of shell archive.
  236. exit 0
  237.