//选择排序var arNums = [65, 52, 74, 14, -1, 2, 88];var b = 0;for (var i = 0; i < arNums.length; i++) { for (var j = i+1; j < arNums.length; j++) { if (arNums[i] > arNums[j]) { a = arNums[i]; arNums[i] = arNums[j]; arNums[j] = a; } }}for (var i in arNums) { console.log(i) if (i != arNums.length - 1) { document.write(arNums[i] + ‘,‘); } else { document.write(arNums[i]); }}
原文地址:https://www.cnblogs.com/zxk5625/p/10290082.html
时间: 2024-10-16 02:14:49