From 3f5945ca8c3a4cd7f4bb1e08d40dca1503fd0fa8 Mon Sep 17 00:00:00 2001 From: ZennDev1337 Date: Mon, 5 Feb 2024 12:24:53 +0100 Subject: [PATCH] update --- src/io.h | 8 ++++---- src/main.cpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/io.h b/src/io.h index 16eba01..2ac5eb8 100644 --- a/src/io.h +++ b/src/io.h @@ -7,11 +7,11 @@ void convert_char_to_ascii(); void print_type_size_bytes(); template -void bubble_sort(T *a) +void bubble_sort(int size, T *a) { - for (int i = 0; i < sizeof(&a) / sizeof(a); i++) + for (int i = 0; i < size; i++) { - for (int j = 0; j < 7 - 1 - i; j++) + for (int j = 0; j < size - 1 - i; j++) { if (a[j] > a[j + 1]) { @@ -29,7 +29,7 @@ void bubble_sort_print(int size, T *a) for (int i = 0; i < size; i++) std::cout << a[i] << ", "; std::cout << "\n"; - bubble_sort(a); + bubble_sort(size, a); std::cout << "sorted Array: "; for (int i = 0; i < size; i++) std::cout << a[i] << ", "; diff --git a/src/main.cpp b/src/main.cpp index 92dd2f4..9c84a8e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4,7 +4,7 @@ int main() { int demo[]{11, 14, 3, 18, 8, 17, 43, 6, 5, 4}; - double demo2[]{11.2, 14.3, 3.2, 18.6, 8.7, 17.9, 43.3}; + double demo2[]{11.2, 14.3, 3.2, 18.6, 8.7, 17.9, 43.3, 12.3}; // add_two_numbers(); // convert_char_to_ascii(); print_type_size_bytes();