diff options
author | JSDurand <mmemmew@gmail.com> | 2023-03-09 17:15:06 +0800 |
---|---|---|
committer | JSDurand <mmemmew@gmail.com> | 2023-03-09 17:15:06 +0800 |
commit | 45394c7cc8f6191e88edd6280b308ae69f588376 (patch) | |
tree | 864fe30ecc435cb7d773145d0901bceed8c149ae /src | |
parent | 2c3ec9a3e8a33e49cdcb8c17037e8ccc66aca989 (diff) |
Minor modifications
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; |