3
I’m trying to make C the game cho-han bakuchi. It is quite simple, the Japanese game consists of throwing two 6-sided dice into a cup, before the dice are shown the player makes the bet saying cho (pairs) or han (odd). Then displays the data and the values are summed.
What I’m missing in my code?
I wouldn’t like the full code, just the point I’m missing so I can make the correction.
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i,x,apost,cred=100,result=0;
while(apost!=EOF)
{
printf("faça a aposta:(digite -1 para sair)\n");
scanf("%d", &apost);
cred=cred-apost;
printf("escolha 1-cho(par) 2-han(impar):\n");
scanf("%d", &x);
switch(getc(x))
{
case 1:
i=2+rand()%12;
printf("\n%10d", i);
if(i%2==0)
{
printf("ganhou!\n");
cred=cred+(apost*2);
}
else
printf("perdeu!");
break;
case 2:
i=2+rand()%12;
printf("\n%10d", i);
if(i%2!=0)
{
printf("ganhou!\n");
cred=cred+(apost*2);
}
else
printf("perdeu!");
}
}
return 0;
}
In the edition you changed the code on
case 1:
. Are you sure that’s right?– Guilherme Bernal
So William I’m learning I’m not sure I’m making attempts and keeping the code updated
– Leonardo V. De Gasperin
Do not change the question code. Use the one from the moment you had the doubt and keep it that way. Note the edition history to know right what has changed. The idea is that the question does not lose context with the answer to a future reader.
– Guilherme Bernal
ok but good I’ll leave it so because I’m no longer moving in the code (for now) I know q can not be 2+Rand()%12 and yes 1+Rand()%6 twice, as I do to add that I can put the result within an aux?
– Leonardo V. De Gasperin
int i = 0; i += 1+rand()%6; i += 1+rand()%6; printf("%d", i);
– Guilherme Bernal