diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs index 301ca32..64709b1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -109,6 +109,12 @@ fn sm<T: PartialOrd>(a: Vec<T>, count: &mut usize) -> Vec<usize> { let hi = *g_to_a_s.last().unwrap().get(hi).unwrap(); result.push(hi); + + if i + 1 == n { + // early break to prevent unnecessary efforts + break; + } + *added.get_mut(hi).unwrap() = true; lis.push(li); @@ -157,6 +163,11 @@ fn main() { // println!(" {enumeration:?}"); + if inputs.is_empty() { + println!("Please input some numbers to sort."); + return; + } + println!("inputs: {inputs:?}"); let mut count = 0; |