Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #include<set>
- using namespace std;
- int main(){
- //---Vector---
- //vector<tipo> nome;
- /*
- vector<int> v;
- printf("%d\n", v.size());
- v.push_back(5);
- printf("%d\n", v.size());
- printf("%d\n", v[0]);
- v.pop_back();
- printf("%d\n", v.size());
- v.push_back(1);
- v.push_back(2);
- v.push_back(3);
- v.push_back(4);
- v.push_back(5);
- for(int i = 0; i < v.size(); i++)
- printf("%d\n", v[i]);
- v.erase();
- v.begin(); == &v[0];
- v.end(); == &v[4];
- v.resize(10, 1);
- */
- //---Set---
- //Set é um vetor sempre ordenado que não repete elementos.
- set<int> s; //É um conjunto ordenado onde os elementos não se reprtem
- s.insert(1);// s = {1}
- s.insert(3);// s = {1,3}
- s.insert(2);// s = {1,2,3}
- s.insert(2);// s = {1,2,3}
- s.erase(1);//Apaga o elemento do set
- if(s.find(3) != s.end()){cout<<"contem 3" << endl;}
- set<int>:: iterator it;
- for(it = s.begin(); it != s.end(); it++){
- printf("%d\n", *it);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement