C언어 질문입니다.!
뿌우
#include stdio.h
#include time.h
#include stdlib.h
int main(void)
{
int car, choice, third, newchoice;
int ans, cont, tmp, temp;
int win = 0, total = 0;
printf(입력횟수:);
scanf_s(%d, &cont);
while (cont total){
srand((unsigned int)time(NULL)); //시간별 난수발생
car = rand() % 3 + 1; // car를 1~3중 하나로 랜덤하게 pick
choice = 1 + (car + rand() % 2) % 3; //choice도 1~3중 하나로 랜덤하게 pick
while (1){ // third는 choice도 car도 아닌 값
tmp = rand() % 3 + 1;
if (tmp != choice && tmp != car)
break;
}
third = tmp;
while (1){ // newchoice는 choice도 third도 아닌 값
temp = rand() % 3 + 1;
if (temp != choice && temp != third)
break;
}
newchoice = temp;
if (newchoice == car){
win = win + 1;
}
total = total + 1;
printf(win/total=%d/%d\n, win, total);
}
}몬티홀문제에서 첫선택을 무조건 바꾸는 경우(third가 아닌값으로)에
win/total 값을 출력하는 걸 만들려고 하는대요 (win은 바꿧을때 자동차를 pick)
win/total 이 계속 100프로 더라고요 (1/1 2/2 3/3 4/4 ...)
뭐가 잘못댔을까요..?