|
发表于 2007-12-23 13:10:00
|
显示全部楼层
Re:继续转题……这次是逻辑题
cls
dim as integer i,p,c,d,t,s,k
randomize timer
s=0
k=1000000
for i=1 to k
p=int(rnd*3)
c=int(rnd*3)
if p=c then
t=3-p
if t=1 then d=int(rnd*2)
if t=2 then d=int(rnd*2)*2
if t=3 then d=int(rnd*2)+1
else
d=3-p-c
end if
'print "Car at door";p+1;", Chose door";c+1;", Host opened door";d+1
'print "Then change mind, ";
if 3-d-c=p then
'print "and got the car!"
s=s+1
else
'print "and not got the car..."
end if
next i
print "Chance:";s*100/k;"%";
sleep
实验证明,概率为2/3 |
|