- #include<bits/stdc++.h>
- using namespace std;
- //unordered_set<int> us; //1
- //unordered_set<int> us={1,1,2,3,5,3,4}; //2
- /*int arr[8]={1,1,2,3,5,3,4,7}; //3
- unordered_set<int> us(arr, arr+8);*/
- vector<int> v={1,1,2,3,5,3,4,7}; //4
- unordered_set<int> us(v.begin(), v.end());
- int main()
- {
- cin.tie(0);
- cin.sync_with_stdio(0);
- /*
- us.insert(1);
- us.insert(2);
- us.insert(7);
- us.insert(5);
- us.insert(2);
- us.insert(1);
- */
- for(int i: us)
- cout<<i<<endl;
- cout<<"----------"<<endl;
- cout<<us.size()<<endl;
- cout<<us.count(2)<<endl;
- cout<<us.count(8)<<endl;
- return 0;
- }
複製代碼 |