for(var j = 1 ;j<arr.length;j++){
for(var i = 0 ;i<arr.length-j;i++){
if(arr[i]>arr[i+1]){
var temp = arr[i];
arr[i] = arr[i+1];
arr[i+1] = temp;
}
}
}
for(var j = 1 ;j<arr.length;j++){
for(var i = 0 ;i<arr.length-j;i++){
if(arr[i]>arr[i+1]){
var temp = arr[i];
arr[i] = arr[i+1];
arr[i+1] = temp;
}
}
}
本文标题:冒泡排序
本文链接:https://www.haomeiwen.com/subject/kvukmxtx.html
网友评论