A*寻路初探
http://blog.vckbase.com/panic/archive/2005/03/20/3778.html
在A*寻路中使用二叉堆
http://my.opera.com/jingze/blog/show.dml/434118

A*寻路初探 http://blog.vckbase.com/panic/archive/2005/03/20/3778.html

在A*寻路中使用二叉堆 http://my.opera.com/jingze/blog/show.dml/434118

  1. 进入ports目录
    cd /usr/ports
  2. 搜索软件
    make search key=[search software]

    Port: gmpc-libnotify-0.19.0_3
    Path: /usr/ports/audio/gmpc-libnotify
    Info: A libnotify for gmpc
    Maint: miwi@FreeBSD.org
    B-deps: ORBit2-2.14.18_1 atk-1.30.0_1 ……

  3. 进入path目录
    cd [Path]
  4. 使用sudo权限安装
    sudo make install

$array = array(1,2,3);
foreach($array as $key => $value){
$array[] = 1;
}
// JavaScript
var array = [1,2,3];
for(key in array){
array.push(1);
}

答案是3!PS: IE那个变态除外,IE会陷入无限循环!

无论在php,还是js中,使用foreach/forin在遍历一个(对象/数组)时,都是即时创建一个(对象/数组)的拷贝
所以:循环中对原遍历(对象/数组)的改变,不会影响循环次数

100%

if( true )

1/2

if( rand(0,1) === 0 )

1/3

if( rand(0,2) === 0 )

1/4

if( rand(0,3) === 0 )

1/x

if( rand(0,x) === 0 )

x%

if( rand(0,99) < x )

x‰

if( rand(0,999) < x )

x‱

if( rand(0,9999) < x )

/**
* 以$x/$y的概率返回true
*
* @param int $x
* @param int $y
* @return bool
*
* prob(1,2) = 1/2
* prob(1,100) = 1/100
*
*/
function prob($x, $y){
return ( mt_rand(0, $y-1) < $x );
}

100%

if( true )

1/2

if( rand(0,1) === 0 )

1/3

if( rand(0,2) === 0 )

1/4

if( rand(0,3) === 0 )

1/x

if( rand(0,x) === 0 )

x%

if( rand(0,99) < x )

x‰

if( rand(0,999) < x )

x‱

if( rand(0,9999) < x )

[php]

/**
* 以$x/$y的概率返回true
*
* @param int $x
* @param int $y
* @return bool
*
* prob(1,2) = 1/2
* prob(1,100) = 1/100
*
*/
function prob($x, $y){
return ( mt_rand(0, $y-1) < $x );
}

[/php]