mirror of
https://github.com/krahets/hello-algo.git
synced 2025-11-03 21:58:48 +08:00
Fix the issue of discussion 514 (#1064)
This commit is contained in:
@ -8,6 +8,9 @@ include!("../include/include.rs");
|
|||||||
|
|
||||||
/* 选择排序 */
|
/* 选择排序 */
|
||||||
fn selection_sort(nums: &mut [i32]) {
|
fn selection_sort(nums: &mut [i32]) {
|
||||||
|
if nums.is_empty() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
let n = nums.len();
|
let n = nums.len();
|
||||||
// 外循环:未排序区间为 [i, n-1]
|
// 外循环:未排序区间为 [i, n-1]
|
||||||
for i in 0..n-1 {
|
for i in 0..n-1 {
|
||||||
|
|||||||
Reference in New Issue
Block a user