当前位置:网站首页>冒泡排序函数封装
冒泡排序函数封装
2022-08-02 00:13:00 【Slxa 安.】
目录
1.js代码
function maoPao(arr){
for(i=0;i<=arr.length;i++){
for(j=0;j<=arr.length;j++){
if(arr[j]>arr[j+1]){
var temp=arr[j];
arr[j]=arr[j+1];
arr[j+1]=temp;
}
}
}
return arr;
}
result=maoPao([3,5,6,2]);
console.log(result);
2.运行结果
边栏推荐
猜你喜欢
随机推荐
基于注意力机制的多特征融合人脸活体检测
uni-app project summary
Statement执行update语句
Realize deletion - a specified letter in a string, such as: the string "abcd", delete the "a" letter in it, the remaining "bcd", you can also pass multiple characters to be deleted, and pass "ab" can
JSP out.write()方法具有什么功能呢?
146. LRU cache
Identify memory functions memset, memcmp, memmove, and memcpy
基于数据驱动的变电站巡检机器人自抗扰控制
Web开发
nodeJs--mime module
Arduino 基础语法
bgp aggregation reflector federation experiment
[HCIP] BGP Small Experiment (Federation, Optimization)
uni-app项目总结
回顾历史5次经济衰退时期:这一次可能会有何不同?
当奈飞的NFT忘记了Web2的业务安全
The Statement update Statement execution
Short video SEO optimization tutorial Self-media SEO optimization skills and methods
Looking back at 5 recessionary times in history: How might this time be different?
众筹DAO“枯萎”的缩影:曾拍下《沙丘》未出版手稿的Spice DAO解散