Skip to content

Instantly share code, notes, and snippets.

@tanvir002700
Last active April 16, 2016 15:19
Show Gist options
  • Select an option

  • Save tanvir002700/7ed06d8fd064cfe9178ff0c6ccbbbfef to your computer and use it in GitHub Desktop.

Select an option

Save tanvir002700/7ed06d8fd064cfe9178ff0c6ccbbbfef to your computer and use it in GitHub Desktop.
#include<iostream>
#include<set>
using namespace std;
int main()
{
set<int>S;
set<int>::iterator it;
for(int i=1;i<100;i++)
{
S.insert(i%10);
}
cout<<"Set size: "<<S.size()<<endl;
cout<<"Set element: ";
for(it=S.begin();it!=S.end();it++)cout<<(*it)<<" ";
cout<<endl;
set<int>::iterator it1,it2;
it1=S.find(4);
it2=S.find(7);
S.erase(it1,it2);
cout<<"Set element after erase 4 to 6: ";
for(it=S.begin();it!=S.end();it++)cout<<(*it)<<" ";
cout<<endl;
S.clear();
cout<<"Is set empty: "<<S.empty()<<endl;
return 0;
}
Set size: 10
Set element: 0 1 2 3 4 5 6 7 8 9
Set element after erase 4 to 6: 0 1 2 3 7 8 9
Is set empty: 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment