冒泡法排序" />

Ace Plugin

Ace Plugin

使gitbook支持ace。

插件地址

安装:

npm install gitbook-plugin-ace --save

配置:

//json.book
"plugins": [
    "ace"
]

使用示例:

{%ace edit=false, lang="php"%}
//This is a hello world program for PHP.=>冒泡法排序实例
function show($arr){

$count = count($arr);       

for($i = 0;$i<$count;$i++){
    for($j = 0;$j<$count-$i-1;$j++){  //$i减少循环次数
        if($arr[$j]>$arr[$j+1]){
            $tmp = $arr[$j];
            $arr[$j] = $arr[$j+1];
            $arr[$j+1] = $tmp;
        }
    }
}

return $arr;

}
{%endace%}

文章导航