mirror of
https://github.com/TheAlgorithms/C
synced 2024-11-21 21:11:57 +03:00
[docs] add documentation group (#556)
* add documentation group * function parameter docs * fix function parameter direction * free dynamic memory
This commit is contained in:
parent
246f3e3f0e
commit
b693440d55
@ -6,6 +6,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/**
|
||||
* @addtogroup sorting Sorting algorithms
|
||||
* @{
|
||||
*/
|
||||
/** Create easy access of elements from a 2D matrix stored in memory as a 1D
|
||||
* array
|
||||
*/
|
||||
@ -13,7 +17,7 @@
|
||||
|
||||
/**
|
||||
* Displays the array, passed to this method
|
||||
* @param [in,out] arr array to display
|
||||
* @param [in] arr array to display
|
||||
* @param [in] n number of elements in the array
|
||||
*/
|
||||
void display(const int *arr, int n)
|
||||
@ -65,6 +69,7 @@ void bead_sort(int *a, size_t len)
|
||||
}
|
||||
free(beads);
|
||||
}
|
||||
/** @} */
|
||||
|
||||
/** Main function */
|
||||
int main(int argc, const char *argv[])
|
||||
|
@ -8,6 +8,10 @@
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
/**
|
||||
* @addtogroup sorting Sorting algorithms
|
||||
* @{
|
||||
*/
|
||||
/** Helper function to print array values */
|
||||
void show_data(int *arr, long len)
|
||||
{
|
||||
@ -15,7 +19,10 @@ void show_data(int *arr, long len)
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
/** Function to swap values of two integers */
|
||||
/** Function to swap values of two integers
|
||||
* @param [in,out] a reference to first variable
|
||||
* @param [in,out] b reference to second variable
|
||||
*/
|
||||
inline void swap(int *a, int *b)
|
||||
{
|
||||
int tmp;
|
||||
@ -26,7 +33,10 @@ inline void swap(int *a, int *b)
|
||||
}
|
||||
|
||||
/**
|
||||
* Shell sort algorithm.\n
|
||||
* Optimized algorithm - takes half the time as other
|
||||
* @param [in,out] array array to sort
|
||||
* @param [in] LEN length of the array
|
||||
*/
|
||||
void shell_sort(int *array, long LEN)
|
||||
{
|
||||
@ -50,6 +60,7 @@ void shell_sort(int *array, long LEN)
|
||||
for (i = 0; i < LEN; i++) printf("%s\t", data[i]);
|
||||
#endif
|
||||
}
|
||||
/** @} */
|
||||
|
||||
/** Main function */
|
||||
int main(int argc, char *argv[])
|
||||
@ -80,5 +91,6 @@ int main(int argc, char *argv[])
|
||||
|
||||
printf("Time spent sorting: %.4g s\n", (t2 - t1) / CLOCKS_PER_SEC);
|
||||
|
||||
free(array);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user