【文章內(nèi)容簡(jiǎn)介】
。程序:clear allclc。total=0。for i=1:1000。 a=0。 b=0。 c=0。 for j=1:100000 x=rand。 y=rand。 if x。 x=1。 else x=1。 end if y a=a+x。 else if y b=b+x。 else c=c+x。 end end if a==0 amp。amp。 b==0 amp。amp。c==0。 pp=j。 total=total+1。 break。 end endendreturn3=total/100。%返回的概率運(yùn)行結(jié)果:可以看到,在這種情況下,%。與前兩種情況不同,青蛙不一定會(huì)回到原點(diǎn)