We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
从数组的开头开始,将第一个元素和其他元素比较,最小的元素会被放到数组第一个位置,再从第二个位置继续。
const selectionStor = arr => { let temp, min, len = arr.length; for(let i = 0; i < len -1; i ++){ min = i; for(let j = i+1; j < len ; j ++){ if(arr[j]<arr[min]){ min = j; } } temp = arr[i]; arr[i] = arr[min]; arr[min] = temp; } return arr; } console.log(selectionStor([1,4,3,5,9,7,3,3,5,3,2]))
The text was updated successfully, but these errors were encountered:
No branches or pull requests
从数组的开头开始,将第一个元素和其他元素比较,最小的元素会被放到数组第一个位置,再从第二个位置继续。
The text was updated successfully, but these errors were encountered: