Help. My brain has stopped working! I need to run this craps program 1000
times and at the end show its stats. Such as how many games are won/lost on the first roll, how many are won/lost on the second roll and so on up to the twentieth roll and then after the twentieth roll. I've worked out how many are won/lost on the first roll but don't know where to go from there?!
Heres what I've got so far
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define SIZE 21
enum Status { CONTINUE, WON, LOST);
int rollDice(void);
int main()
{
int sum;
int myPoint;
int game;
int wins[SIZE] = {0};
int loses[SIZE]= {0};
enum Staus gameStatus;
srand(time(NULL));
for(game = 1; game <= 1000; game++){
sum = rollDice();
switch (sum){
case 7:
case11:
gameStatus = WON;
wins[0]++;
break;
case 2:
case 3:
case 12:
gameStatus = LOST;
default:
gamestatus = CONTINUE;
myPoint = sum;
break;
}
while( gameStatus == CONTINUE){
sum = rollDice();
if( sum == myPoint){
gameStatus = WON;
}
else{
if( sum == 7){
gameStatus = LOST;
}
}
}
}
printf("%d games are won on the first roll\n", wins[0]);
printf("%d games are lost on the first roll\n", loses[0]);
return 0;
}
int rollDice(void)
{
int die1
int die2;
int workSum;
die1 = 1 + (rand() % 6);
die2 = 1 + (rand() % 6);
workSum = die1 + die2;
return workSum;
}