1 Star 0 Fork 0

ArielAsteria/Arithmetic

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
bubbleSort.php 499 Bytes
一键复制 编辑 原始数据 按行查看 历史
Ariel 提交于 2021-03-08 10:40 +08:00 . arithmetic
<?php
function BubbleSort(& $arr)
{
$limit = count($arr); // 计数
for($i=1; $i<$limit; $i++) {
// 按照数组数量进行循环
for($p=$limit-1; $p>=$i; $p--) {
// 内部小循环
if($arr[$p-1] > $arr[$p]) {
$temp = $arr[$p-1];
$arr[$p-1] = $arr[$p]; // 交换大小,交换位置
$arr[$p] = $temp;
}
}
}
}
$data = [3,5,9,32,2,1,2,1,8,5];
BubbleSort($data);
print_r($data);
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/arielaia/Arithmetic.git
git@gitee.com:arielaia/Arithmetic.git
arielaia
Arithmetic
Arithmetic
arithmetic

搜索帮助