Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits.stdc++.h>
- using namespace std;
- int main(){
- set <int, > s;
- /* set<char> myset{ 'A', 'B', 'C', 'D' };
- int a[]= {1, 2, 3, 4, 5, 5};
- set<int> s2 (a, a + 6); */
- for(int i=0;i<n;i++){
- s.insert(a[i]);
- }
- set<int> iterator ::it;
- for(it=s.begin();it!=s.end();it++)
- cout<<*it;
- for(auto it:s)
- cout<<it;
- for(auto it=s.begin();it!+s,end();it++)
- cout<<*it<<" ";
- // set <int> gquiz2(gquiz1.begin(), gquiz1.end())
- //erase in set is same as other stl function ...
- // gquiz2.erase(gquiz2.begin(), gquiz2.find(30));
- s.erase (50); //erases the element 50;
- s.erase(s.begin(),s.end()); //erases in a range
- auto itr = my_multiset.find(value)
- if(itr!=my_multiset.end()){
- my_multiset.erase(itr);
- }
- //PAIR IN SETS
- set<pair<int,int>>s;
- for(int i=0;i<n;i++){
- cin>>x>>y;
- s.insert({x,y});
- }
- set< pair<ll,ll> >::iterator it;
- for(it=s.begin(); it!=s.end(); ++it)
- {
- //first is x, y is the second element
- cout<<it->first<<" "<<it->second<<endl;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment