- Star ⭐ the repository (not necessary but it helps maintainers).
- Fork 🍴 it.
- Create Branch 🌿 with your feature
<feature>
. - Push changes.
- Submit Pull Request 😄.
- Make PR(s) in either
snippets
directory or in one of the following : - If you are feeling confused on what to contribute, head over to Projects, select the directory you want to contribute to for e.g choose
<algorithm>
& from the Algorithms To Implement column select any one method.You can either submit a small C++ code snippet demonstrating the same in thesnippets
directory or submit a overview of the choosen method in<name_of_directory>
see for example all_of.md. - Always follow the style guide.
- Do not update any
README.md
ortodo.txt
files (unless you find a typo 😅) - Enjoy contributing!.
- If you have any doubts, open an issue.
For adding functions in different directories, use the following template (copy from raw format):
Description : < description >.
Example :
// YOUR CODE
std::vector<int> v{ 1, 2, 3, 4, 4, 3, 7, 8, 9, 10 };
// determine how many integers in a std::vector match a target value.
int target1 = 3;
int num_items1 = count(v.begin(), v.end(), target1);
std::cout << "number: " << target1 << " count: " << num_items1 << '\n';
Follow this style guide to add sample programs:
-
Naming Style: For example if you are demonstrating
erase
inlist
name your fileerase.md
and save it in thelist
directory. -
For adding Code Snippets in the
snippets
directory. Add the following comment header in every program. The comment header should always be at the top of program.
/*
Author : this must be your name ;)
Date : Date format dd/mm/yyyy
Time : Time format hh:mm
Description : description should be small & one liner.
*/
- Add Opening braces on the same line.
int main()
{
// ❌
}
int main() {
// ✅.
}
-
Indentation : Use 1 Tab or 4 Spaces. Be consistent with whatever you choose Use only one indenting format for the whole program.
-
Add appropriate comments wherever necessary to explain the code.
Programs wth NO Comments at all will not be merged.
- Expression should be readable, Use 1 space between different tokens.
galaxy=stars+asteroids // ❌
galaxy = stars + asteroids // ✅.
- Always add braces in a for/while loop, even if it's a one-liner.
for (int i = 0; i < 45 ; i++)
std::cout << i << " "; // ❌
for (int i = 0;i < 45; ++i){
std::cout << i << " "; // ✅.
}
-
Always use pre-increment(++i) in loops instead of post-increment(i++).
-
When submitting
markdown
files of methods in different directories, name your file exactly as the function/method name. For examplepush_back.md
,swap.md
etc. -
Always use prefix
std::
for functions and types from the std namespace, either on themarkdown
files or on the snippet code files.
using namespace std; // ❌
vector<int> ...; // ❌
cout << ...; // ❌
std::vector<int> ...; // ✅
std::cout << ...; // ✅
- It is strongly recommended not to use
#include <bits/stdc++.h>
as header file because many compilers do not support this header file.