-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset.cpp
More file actions
55 lines (39 loc) · 1.03 KB
/
Copy pathset.cpp
File metadata and controls
55 lines (39 loc) · 1.03 KB
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(){
set<int>s;
s.insert(1); //insert operation
s.insert(2);
s.insert(3);
s.insert(5);
s.insert(6);
for(int val:s){
cout<<val<<" ";
}
cout<<endl;
//lower_bound: gives if the element exist, or gives the exactly greater value than input otherwise give 0
cout<<"lower bound:"<<*(s.lower_bound(4))<<endl;
//upper_bound: gives the value greater than key
cout<<"upper bound:"<<*(s.upper_bound(5))<<endl;
cout<<"-----------------------unordered set-----------------------"<<endl;
//data will print in any order
unordered_set<int>s2;
s2.insert(1);
s2.insert(2);
s2.insert(3);
for(int val:s2){
cout<<val<<" ";
}
cout<<endl;
cout<<"-----------------------Multiset-----------------------"<<endl;
//duplicated data allowed
multiset<int>ms;
ms.insert(1);
ms.insert(1);
ms.insert(1);
ms.insert(1);
ms.insert(1);
for(int val:ms){
cout<<val<<" ";
}
}