From c9b6b9a5ca082fe7c1b6f58d7713f785a9eb6a5c Mon Sep 17 00:00:00 2001 From: Martial Simon Date: Mon, 15 Sep 2025 01:08:27 +0200 Subject: add: graphs et rushs --- rushs/tinyprintf/bubble_sort/bubble_sort.c | 25 +++++++++++++++++++++++++ rushs/tinyprintf/bubble_sort/bubble_sort.h | 8 ++++++++ 2 files changed, 33 insertions(+) create mode 100644 rushs/tinyprintf/bubble_sort/bubble_sort.c create mode 100644 rushs/tinyprintf/bubble_sort/bubble_sort.h (limited to 'rushs/tinyprintf/bubble_sort') diff --git a/rushs/tinyprintf/bubble_sort/bubble_sort.c b/rushs/tinyprintf/bubble_sort/bubble_sort.c new file mode 100644 index 0000000..13d2ba3 --- /dev/null +++ b/rushs/tinyprintf/bubble_sort/bubble_sort.c @@ -0,0 +1,25 @@ +#include "bubble_sort.h" + +void bubble_sort(int array[], size_t size) +{ + if (!array || size == 0) + { + return; + } + + int mod; + do + { + mod = 0; + for (size_t i = 0; i < size - 1; i++) + { + if (array[i] > array[i + 1]) + { + mod = 1; + int tmp = array[i]; + array[i] = array[i + 1]; + array[i + 1] = tmp; + } + } + } while (mod); +} diff --git a/rushs/tinyprintf/bubble_sort/bubble_sort.h b/rushs/tinyprintf/bubble_sort/bubble_sort.h new file mode 100644 index 0000000..a33d531 --- /dev/null +++ b/rushs/tinyprintf/bubble_sort/bubble_sort.h @@ -0,0 +1,8 @@ +#ifndef BUBBLE_SORT_H +#define BUBBLE_SORT_H + +#include + +void bubble_sort(int array[], size_t size); + +#endif /* !BUBBLE_SORT_H */ -- cgit v1.2.3