-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset.cpp
More file actions
48 lines (38 loc) · 693 Bytes
/
Copy pathset.cpp
File metadata and controls
48 lines (38 loc) · 693 Bytes
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
void insert(set<int> &s,int x)
{
s.insert(x);
//Your code here
}
/*prints the contents of the set s */
void print_contents(set<int> &s)
{
for(const auto&e :s){
cout<<e<<" ";
}
//Your code here
}
/*erases an element x from the set s */
void erase(set<int> &s,int x)
{
s.erase(x);
//Your code here
}
/*returns 1 if the element x is
present in set s else returns -1 */
int find(set<int> &s,int x)
{
int b=-1;
set<int>::iterator itr;
for (itr = s.begin(); itr!= s.end(); ++itr)
{ if(*itr==x)
{ b=1;break;}
}
return b;
//Your code here
}
/*returns the size of the set s */
int size(set<int> &s)
{
return s.size();
//Your code here
}