insert(): This function is a build-in function in STL. This function attempts
to insert a list of elements into the set.
Parameters:
__l – A std::initializer_list<value_type> of elements to be inserted.
Complexity is similar to that of the range constructor.
Syntax:
st.insert(__l)
For Example:
st.insert({1,4,5,6,1,2}) = > Set becomes ={1,2,4,5,6}
Approach
C++
#include <bits/stdc++.h>using namespace std;int main(){set<int> st;st.insert({1, 4, 5, 6, 1, 2});for (auto it = st.begin(); it != st.end(); it++)cout << *it << " ";return 0;}
No comments:
Post a Comment