Welcome to TheAlgorithms/C! Before submitting pull requests, please make sure that you have read the whole guidelines. If you have any doubts about this contribution guide, please open an issue or ask in our Discord server, and clearly state your concerns.
Please check the reviewer code file for maintainers and reviewers.
Being a contributor at The Algorithms, we request you to follow the points mentioned below:
New implementation New implementations are welcome!
You can add new algorithms or data structures which are not present in the repository or that can improve the old implementations (documentation, improving test cases, removing bugs or in any other resonable sense)
Issues Please avoid opening issues asking to be "assigned” to a particular algorithm. This merely creates unnecessary noise for maintainers. Instead, please submit your implementation in a pull request, and it will be evaluated by project maintainers.
*.h
*.c
struct
keywordREADME.md
along with other changes. First, create an issue and then link to that issue in your pull request to suggest specific changes required to README.md
.main()
function.test()
functions that will invoke the algorithm implementation on random test data with the expected output. Use the assert()
function to confirm that the tests will pass. Requires including the assert.h
library./**
* @file
* @brief Add one line description here
* @details
* This is a multi-line
* description containing links, references,
* math equations, etc.
* @author [Name](https://github.com/handle)
* @see related_file.c, another_file.c
*/
#include <assert.h> /// for assert
#include /// for `some function here`
/**
* @brief Struct documentation
*/
struct struct_name {
int variable; ///< short info of this variable
char message; ///< short info
};
/**
* @brief Function documentation
* @param param1 one-line info about param1
* @param param2 one-line info about param2
* @returns `true` if ...
* @returns `false` if ...
*/
bool func(int param1, int param2) {
// function statements here
if (/*something bad*/) {
return false;
}
return true;
}
/**
* @brief Self-test implementations
* @returns void
*/
static void test() {
/* desciptions of the following test */
assert(func(...) == ...); // this ensures that the algorithm works as expected
// can have multiple checks
}
/**
* @brief Main function
* @returns 0 on exit
*/
int main() {
test(); // run self-test implementations
// code here
return 0;
}
"_"
as a separatorMyNewCStruct.C is incorrect
my_new_c_struct.c is correct format
median_search.c
already exists in the search
folder, and you are contributing a new implementation, the filename should be median_search2.c
and for a third implementation, median_search3.c
."_"
as separator ( no spaces or "-"
allowed )SomeNew Fancy-Category is incorrect
some_new_fancy_category is correct
git add file_xyz.c
git commit -m "your message"
Examples of commit messages with semantic prefixes:
fix: xyz algorithm bug
feat: add xyx algorithm, struct xyz
test: add test for xyz algorithm
docs: add comments and explanation to xyz algorithm
Common prefixes:
Before submitting a pull request, build the code locally or using the convenient service.
cmake -B build -S .
We use clang-tidy as a static code analyzer with a configuration in .clang-tidy.
clang-tidy --fix --quiet -p build subfolder/file_to_check.c --
clang-format is used for code forrmating.
brew install clang-format
sudo port install clang-10 +analyzer
pacman -S mingw-w64-x86_64-clang-tools-extra
sudo apt-get install clang-format-10 clang-tidy-10
clang-format -i -style="file" my_file.c
clang-tidy
and clang-format
after every a push (not a commit).
git pull
in your local clone if these actions made many changes to avoid merge conflicts.Most importantly,
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。