Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
文件
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
3-6按从大到小排序.html 571 Bytes
Copy Edit Raw Blame History
Alan authored 2024-04-02 11:19 . web3,4
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>冒泡排序</title>
</head>
<body>
</body>
</html>
<script>
var arr = [100, 98, 70, 67, 59, 49, 35, 20];
for (var i = 0; i <= arr.length - 1; i++) {
for (var j = 0; j <= arr.length - i; j++) {
//前一项和后一项比较
if (arr[j] > arr[j - 1]) {
//两值交换
var temp = arr[j];
arr[j] = arr[j - 1];
arr[j - 1] = temp
}
}
}
console.log(arr);
</script>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化