diff --git a/guide/english/cplusplus/c-stl-sets/index.md b/guide/english/cplusplus/c-stl-sets/index.md index a65fb53018..eb88ffdc72 100644 --- a/guide/english/cplusplus/c-stl-sets/index.md +++ b/guide/english/cplusplus/c-stl-sets/index.md @@ -3,7 +3,7 @@ title: C++ STL Sets --- ## Introduction of sets in C++ STL library -Sets are a type of associative containers in which each element has to be unique.The value of the element cannot be modified once it is added to the set, though it is possible to remove and add the modified value of that element. They are implemented using red-black tree. +Sets are a type of associative container in which each element has to be unique. The value of the element cannot be modified once it is added to the set, though it is possible to remove and add the modified value of that element. They are implemented using [red-black tree](https://guide.freecodecamp.org/algorithms/red-black-trees/). ## Benefits of using sets 1. It stores only unique values. @@ -13,8 +13,11 @@ Sets are a type of associative containers in which each element has to be unique Example: ```c++ -#include -using namespace std; +#include +#include +using std::set; +using std::cout; +using std::endl; int main() { set s; @@ -25,13 +28,14 @@ int main() s.insert(2); //inserting same element 2 s.insert(6); for(auto i:s) - cout<::iterator it; -for(it=s.begin(); it!=s.end(); ++it) - cout<<*it; +for(it = s.begin(); it != s.end(); ++it) + cout << *it; ```