本文主要是介绍bubbleSort.html,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript">function bubbleSort(arr){var len = arr.length;for (var i = 0; i < len - 1; i++){for (var j = 0; j < len - 1 - i; j++){if (arr[j] > arr[j + 1]){var temp = arr[j];arr[j] = arr[j + 1];arr[j + 1] = temp;}}}return arr;}var arrayUnsorted =[64, 34, 25, 12, 22, 11, 90];function init(){var arraySorted = bubbleSort(arrayUnsorted);console.log("排序后的数组:" + arraySorted);}//http://127.0.0.1:7070/PrjJsp/customElement/cejs.html//http://127.0.0.1:7070/PrjJsp/bubbleSort/bubbleSort.html
</script>
</head>
<body onload="init()"></body>
</html>
这篇关于bubbleSort.html的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!