summaryrefslogtreecommitdiff
path: root/rushs/tinyprintf/selection_sort
diff options
context:
space:
mode:
Diffstat (limited to 'rushs/tinyprintf/selection_sort')
-rw-r--r--rushs/tinyprintf/selection_sort/selection_sort.c30
1 files changed, 0 insertions, 30 deletions
diff --git a/rushs/tinyprintf/selection_sort/selection_sort.c b/rushs/tinyprintf/selection_sort/selection_sort.c
deleted file mode 100644
index 98adc7e..0000000
--- a/rushs/tinyprintf/selection_sort/selection_sort.c
+++ /dev/null
@@ -1,30 +0,0 @@
-#include <stddef.h>
-
-void swap(int *a, int *b)
-{
- int tmp = *a;
- *a = *b;
- *b = tmp;
-}
-
-unsigned array_min(const int arr[], unsigned start, unsigned size)
-{
- unsigned min = start;
- for (; start < size; start++)
- {
- if (arr[min] > arr[start])
- {
- min = start;
- }
- }
- return min;
-}
-
-void selection_sort(int arr[], unsigned size)
-{
- for (size_t i = 0; i < size; i++)
- {
- unsigned j = array_min(arr, i, size);
- swap(&(arr[i]), &(arr[j]));
- }
-}