From ec57c8fa405cb70ac8c82bed9975d0b44f476ca8 Mon Sep 17 00:00:00 2001 From: Krishna Vedala <7001608+kvedala@users.noreply.github.com> Date: Wed, 1 Jul 2020 20:58:44 -0400 Subject: [PATCH] docs + fix lgtm alert https://lgtm.com/projects/g/TheAlgorithms/C/snapshot/4d0dbc401d67171d555d494c49a08e72303b5ba7/files/sorting/bead_sort.c?sort=name&dir=ASC&mode=heatmap#xdc9736f163b5f58d:1 --- sorting/bead_sort.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/sorting/bead_sort.c b/sorting/bead_sort.c index 979bac68..36fc480d 100644 --- a/sorting/bead_sort.c +++ b/sorting/bead_sort.c @@ -1,12 +1,23 @@ -// sorting of array list using bead sort +/** + * @file + * @brief sorting of array list using bead sort + */ #include #include -/*Displays the array, passed to this method*/ -void display(int *arr, int n) +/** Create easy access of elements from a 2D matrix stored in memory as a 1D + * array + */ +#define BEAD(i, j) beads[i * max + j] + +/** + * Displays the array, passed to this method + * @param [in,out] arr array to display + * @param [in] n number of elements in the array + */ +void display(const int *arr, int n) { - int i; - for (i = 0; i < n; i++) + for (int i = 0; i < n; i++) { printf("%d ", arr[i]); } @@ -14,15 +25,14 @@ void display(int *arr, int n) printf("\n"); } -/*This is where the sorting of the array takes place - a --- Array to be sorted - len --- Array Size +/** This is where the sorting of the array takes place + * @param [in,out] a array to be sorted + * @param [in] len Array Size */ -void bead_sort(int *a, int len) +void bead_sort(int *a, size_t len) { int i, j, max, sum; unsigned char *beads; -#define BEAD(i, j) beads[i * max + j] for (i = 1, max = a[0]; i < len; i++) if (a[i] > max) @@ -55,6 +65,7 @@ void bead_sort(int *a, int len) free(beads); } +/** Main function */ int main(int argc, const char *argv[]) { int n;