Last active
October 13, 2017 12:42
-
-
Save Nick0603/16a6e409423147670c8e6eb04675d3ce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var nums = [2,7,4,6,3]; | |
console.log("排序前:"); | |
console.log(nums); | |
console.log("排序過程:"); | |
for(var i=0;i<nums.length;i++){ | |
for(var j=1;j<nums.length;j++){ | |
if( nums[j-1] > nums[j]){ | |
var temp = nums[j]; | |
nums[j ] = nums[j-1]; | |
nums[j-1] = temp; | |
} | |
} | |
console.log(nums); | |
} | |
console.log("排序後:"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment