标签:length 冒泡 OLE lse console ons log for document
//冒泡排序
var arNum = [13, 12, 4, 131, 57, 2, 59];
var a = 0;
for (var j = 0; j < arNum.length; j++) {
for (var k = 0; k < arNum.length - j; k++) {
if (arNum[k] > arNum[k + 1]) {
a = arNum[k];
arNum[k] = arNum[k + 1];
arNum[k + 1] = a;
}
}
}
for (var i in arNum) {
console.log(i)
if (i != arNum.length - 1) {
document.write(arNum[i] + ‘,‘);
} else {
document.write(arNum[i]);
}
}
标签:length 冒泡 OLE lse console ons log for document
原文地址:https://www.cnblogs.com/zxk5625/p/10290079.html