#include #include int main(){ int r1,r2,r3,i,x,y,z; srand(time(NULL)); printf("Let's start to play the game with 3 dices\n"); printf("your balance = $"); scanf("%d",&x); do{ do{ printf("how much do you invest? $"); scanf("%d", &y); if(y>x){ printf("how much do you invest? $"); scanf("%d",&y); } }while(y>x); printf("what is your expectes outcome, big(1) or small(0)? "); scanf("%d",&z); r1=rand()%6+1; do{ r2=rand()%6+1; if(r2==r1) r2=rand()%6+1; }while(r2==r1); do{ r3=rand()%6+1; if(r1==r3||r2==r3) r3=rand()%6+1; }while(r1==r3||r1==r2); printf("the points of the 3 dices are %d %d %d\n",r1,r2,r3); i=r1+r2+r3; if(z==1&&i>=3&&i<10){ printf("it is small, an incorrect guess\n"); printf("your balance = $%d\n",x-y); x=x-y; } else if(z==0&&i>=3&&i<10){ printf("it is small, a correct guess\n"); printf("your balance = $%d\n",x+y); x=x+y; } else if(z==1&&i>=11&&i<=18){ printf("it is big, a correct guess\n"); printf("your balance = $%d\n",x+y); x=x+y; } else{ printf("it is small, an incorrect guess\n"); printf("your balance = $%d\n",x-y); x=x-y; } printf("\n"); }while(x>0); return 0; }