-
Notifications
You must be signed in to change notification settings - Fork 495
/
Copy pathunordered_set.cpp
55 lines (49 loc) Β· 1.02 KB
/
unordered_set.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include<bits/stdc++.h>
using namespace std;
int main(){
unordered_set<int>un;
cout<<"enter unordered_set size->";
int m;
cin>>m;
for(int i=0;i<m;i++){
int val;
cout<<"enter Value->";
cin>>val;
un.insert(val);
}
cout<<endl;
cout<<"Size of unordered_Set ->"<<un.size()<<endl;
cout<<"display unordered_Set elements->"<<endl;
for(auto it=un.begin(); it!=un.end(); it++){
cout<<*it<<" ";
}
cout<<endl;
cout<<"Searching in unordered_Set->"<<endl;
cout<<"Find the element You are in Search for->";
int k;
cin>>k;
if(un.find(k)!=un.end())
{
cout<<k<<" is present";
}
else
{
cout<<k<<" is not present";
}
cout<<endl;
}
/* OUTPUT:
enter unordered_set size->6
enter Value->10
enter Value->8
enter Value->12
enter Value->1
enter Value->10
enter Value->7
Size of unordered_Set ->5
display unordered_Set elements->
7 10 8 12 1
Searching in unordered_Set->
Find the element You are in Search for->15
15 is not present
*/