There is a program that simulates a coin toss. The problem is that, logically, it should throw out about 50 to 50 (Eagle-Reshka), but why is the ratio around 30 to 70, why can you explain this? (Devc ++, win7)
#include <stdio.h> #include <stdlib.h> #include <time.h> int flip(void); main() { srand(time(NULL)); int sumReshka = 0, sumOrel = 0; for (int i = 1; i <= 100; i++) { if (flip() == 0) { sumReshka++; printf("Reshka\n"); } else { sumOrel++; printf("Orel\n"); } } printf("Kol-vo reshek - %d, Kol-vo orlov - %d\n", sumReshka, sumOrel); system("PAUSE"); } int flip(void) { if ((rand() % 2) == 1) return 1; else if ((rand() % 2) == 0) return 0; }
return
'but in theflip
function. - VladD