[c++/en] consistent indentation

This commit is contained in:
Boris Verkhovskiy 2024-05-17 11:52:08 -06:00
parent 825a2b0875
commit 389f2c2956

View File

@ -933,7 +933,7 @@ ST.erase(20); // Will erase element with value 20
// Set ST: 10 30
// To iterate through Set we use iterators
std::set<int>::iterator it;
for(it = ST.begin(); it != ST.end(); it++) {
for (it = ST.begin(); it != ST.end(); it++) {
std::cout << *it << '\n';
}
// Output:
@ -963,7 +963,7 @@ mymap.insert(pair<char,int>('Z',26));
// To iterate
std::map<char,int>::iterator it;
for (it=mymap.begin(); it!=mymap.end(); ++it)
for (it = mymap.begin(); it != mymap.end(); ++it)
std::cout << it->first << "->" << it->second << '\n';
// Output:
// A->1
@ -1033,7 +1033,7 @@ std::sort(tester.begin(), tester.end(), [](const pair<int, int>& lhs, const pair
std::vector<int> dog_ids;
// number_of_dogs = 3;
for(int i = 0; i < 3; i++) {
for (int i = 0; i < 3; i++) {
dog_ids.push_back(i);
}
@ -1057,14 +1057,14 @@ sort(dog_ids.begin(), dog_ids.end(), [&weight](const int &lhs, const int &rhs) {
// You can use a range for loop to iterate over a container
int arr[] = {1, 10, 3};
for(int elem: arr){
for (int elem: arr) {
cout << elem << endl;
}
// You can use "auto" and not worry about the type of the elements of the container
// For example:
for(auto elem: arr) {
for (auto elem: arr) {
// Do something with each element of arr
}
@ -1212,7 +1212,7 @@ compl 4 // Performs a bitwise not
## Further Reading:
* An up-to-date language reference can be found at [CPP Reference](http://cppreference.com/w/cpp).
* A tutorial for beginners or experts, covering many modern features and good practices: [LearnCpp.com](https://www.learncpp.com/)
* A tutorial covering basics of language and setting up coding environment is available at [TheChernoProject - C++](https://www.youtube.com/playlist?list=PLlrATfBNZ98dudnM48yfGUldqGD0S4FFb).
* Additional resources may be found at [CPlusPlus](http://cplusplus.com).
- An up-to-date language reference can be found at [CPP Reference](http://cppreference.com/w/cpp).
- A tutorial for beginners or experts, covering many modern features and good practices: [LearnCpp.com](https://www.learncpp.com/)
- A tutorial covering basics of language and setting up coding environment is available at [TheChernoProject - C++](https://www.youtube.com/playlist?list=PLlrATfBNZ98dudnM48yfGUldqGD0S4FFb).
- Additional resources may be found at [CPlusPlus](http://cplusplus.com).