我也貼程式碼...
代碼:
<?php
$times = 10000;
$totalcount = 0;
for( $o=1; $o<=$times; $o++)
{
$array1 = array(1,1,1,1,1,1,1,1,1,1);
$array2 = array(1,1,1,1,1,1,1,1,1,1);
srand((double)microtime()*1000000);
$coun1 = 0;
while($coun1<3)
{
$a = rand(0,1000)%10;
if( $array1[$a] == 1 )
{
$array1[$a] = 0;
$coun1++;
}
if( $coun1 == 3 )
break;
}
$coun2 = 0;
while($coun2<3)
{
$b = rand(0,100000)%10;
if( $array2[$b] == 1 )
{
$array2[$b] = 0;
$coun2++;
}
if( $coun2 == 3 )
break;
}
$diff = 0;
for( $i=0; $i<=9; $i++ )
{
if( $array1[$i] != $array2[$i] )
$diff++;
}
if( $diff == 6 )
$totalcount++;
} //FOR LOOP ENDS
echo $totalcount/$times;
?>