我说了 你做一个记数器 然后统计下你程序换中奖情况 测试的次数越高就会越接近2/3

How are you 怎么是你?
How old are you 怎么老是你?
2008-01-19 03:37
2008-01-19 03:38
2008-01-19 03:41
2008-01-19 03:41

2008-01-19 03:48
2008-01-19 03:50
2008-01-19 03:54
程序代码:#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#define N 1000000
int main()
{
srand((unsigned)time(NULL));
long xuan,che,huan=0,buhuan=0;
for(long i=0;i!=N;++i)
{
che=rand()%3;
xuan=rand()%3;
if(xuan==che) ++buhuan;
else ++huan;
}
printf("不换赢得车的次数:%ld,赢率%f\n换赢得车的次数%ld,赢率%f\n",buhuan,(double)buhuan/N,huan,(double)huan/N);
return 0;
} 其实看了逻辑,不上机运行也知道结果了

2008-01-19 03:55

2008-01-19 04:00
2008-01-19 04:02