Last active
April 16, 2016 15:19
-
-
Save tanvir002700/7ed06d8fd064cfe9178ff0c6ccbbbfef to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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