From 49125ee42838886e9621be5a4c84a34b40cf336e Mon Sep 17 00:00:00 2001 From: jacekpoz Date: Wed, 8 May 2024 20:09:47 +0200 Subject: [PATCH] add ordinal indicator to the output --- lab3/zad1/rand_select/src/main.rs | 8 +++++++- lab3/zad1/select/src/main.rs | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lab3/zad1/rand_select/src/main.rs b/lab3/zad1/rand_select/src/main.rs index 2ed99e7..0eeb106 100644 --- a/lab3/zad1/rand_select/src/main.rs +++ b/lab3/zad1/rand_select/src/main.rs @@ -48,7 +48,13 @@ fn main() -> io::Result<()> { println!("end state: {:?}", list); let mut insertion = InsertionSort::new(false); println!("sorted array: {:?}", insertion.sort(&input_list)); - println!("{} order statistic: {}", order_statistic, result); + let ordinal_indicator = match order_statistic { + 1 => "st", + 2 => "nd", + 3 => "rd", + _ => "th", + }; + println!("{}{} order statistic: {}", order_statistic, ordinal_indicator, result); } println!("swaps: {}", randomized.num_swap()); diff --git a/lab3/zad1/select/src/main.rs b/lab3/zad1/select/src/main.rs index 44607f7..40f132c 100644 --- a/lab3/zad1/select/src/main.rs +++ b/lab3/zad1/select/src/main.rs @@ -48,7 +48,13 @@ fn main() -> io::Result<()> { println!("end state: {:?}", list); let mut insertion = InsertionSort::new(false); println!("sorted array: {:?}", insertion.sort(&input_list)); - println!("{} order statistic: {}", order_statistic, result); + let ordinal_indicator = match order_statistic { + 1 => "st", + 2 => "nd", + 3 => "rd", + _ => "th", + }; + println!("{}{} order statistic: {}", order_statistic, ordinal_indicator, result); } println!("swaps: {}", normal.num_swap());