/* File: craps.c A modified version of the craps program that uses our random number library. */ #include #include "genlib.h" #include "simpio.h" #include "random.h" main() { int point, throw, r1, r2 ; string dummy ; SetRandomSeed() ; SetRandomRange(1, 6) ; printf("Ready for a game of craps.\n") ; printf("Press for your first throw...") ; dummy = GetLine() ; r1 = GetRandomNumber() ; r2 = GetRandomNumber() ; throw = r1 + r2 ; printf("You rolled a %d.\n", throw) ; if (throw == 7) { printf("You win!!!\n") ; } else if (throw == 11) { printf("A natural! You win!!!\n") ; } else if ( (throw == 2) || (throw == 3) ) { printf("Oh well, you lose\n") ; } else if ( throw == 12 ) { printf("Craps, you lose\n") ; } else { point = throw ; while (TRUE) { printf("Press for the next throw...") ; dummy = GetLine() ; r1 = GetRandomNumber() ; r2 = GetRandomNumber() ; throw = r1 + r2 ; printf("You rolled a %d.\n", throw) ; if (throw == point) { printf("You made your point! You win!!!\n") ; break ; } else if (throw == 7) { printf("You crapped out, you lose\n") ; break ; } } } printf("End of Game\n\n") ; }