有 5个数字,2;3;1;0;4,按大小顺序排列
<script type="text/javascript"> var arr =new Array(); arr .push(2); arr.push(3); arr .push(1); arr .push(0); arr .push(4); var temp; for (var i =0;i<arr.length; i++){ for (var j =i+1;j <arr.length;j++){ if(arr[i]>arr[j]){ temp =arr[i]; arr[i]=arr[j]; arr[j]=temp; } } } for(var x in arr){ alert(arr[x]); } </script>
时间: 2024-10-28 09:04:14