A common dice game named Sic Bo101utilizes three dice. And one of the gameplay options is Odd or Even, that is: A player may place wagers:
(a) “Odd”, which shall:
I. win if any of the totals 5, 7, 9, 11, 13, 15 or 17 appears in any combination of the three dice, except in the case of triple 3 or triple 5, and
II. lose if any other total appears, or if the totals 9 or 15 are determined as a result of the combination of the dice showing triple 3 or triple 5 respectively.
(b) “Even”, which shall:
I. win if any of the totals 4, 6, 8, 10, 12, 14 or 16 appears in any combination of the three dice, except in the case of triple 2 or triple 4, and
II. lose if any other total appears, or if the totals 6 or 12 are determined as a result of the combination of the dice showing triple 2 or triple 4 respectively.
Please write a program that play the game described above 1000 times with a random bet on “odd” or “even” and calculate the player’s wining
percentage.
Or you can find answer here.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
float ranme(int seq) {
int bet = (rand()%2);
int dice1 = (rand()%6)+1;
int dice2 = (rand()%6)+1;
int dice3 = (rand()%6)+1;
int sum = dice1+dice2+dice3;
int winlose = 0;
char arrEO[2][5] = {"even", "odd"};
char arrWL[2][5] = {"Lose", "Win"};
if ((dice1==dice2)&&(dice2==dice3)) {
winlose = 0;
//printf("%d All dices was:%d %s\n",seq, dice1, arrWL[winlose]);
} else {
winlose = (sum%2)==bet ? 1: 0;
//printf("%d Bet in %s and sum was %d , %s\n", seq, arrEO[bet], sum, arrWL[winlose]);
}
return (float)winlose;
}
void main() {
float N = 1000.0;
float sum = 0.0;
srand(time(NULL));
for (float i=0;i<N;i+=1) {
sum += ranme(i+1);
}
printf("Win %.0f from %.0f times, percentage is %.2f\n", sum, N, (sum/N)*100.0);
}
I don't think anyone off of the internet can tell you how to write the program, you need someone in person to teach you. I wanted to learn the program behind this link in https://www.dashtech.org/the-importance-of-technology-in-education/. Only a professional in person was able to help me with this!
Hi there, I found your blog via Google while searching for a time card calculator and your post looks very interesting to me.